Commit 18f3a9427eb50ad5cce81ca288899e97bbf6aa76

Authored by 廖磊
2 parents 6af4597f 2033f1c4

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

minhang
Showing 36 changed files with 1838 additions and 1547 deletions

Too many changes to show.

To preserve performance only 36 of 99 files are displayed.

src/main/java/com/bsth/controller/BusIntervalController.java
... ... @@ -22,6 +22,11 @@ public class BusIntervalController {
22 22 public List<Map<String,Object>> getDir(@RequestParam Map<String, Object> map){
23 23 return busIntervalService.getDir(map);
24 24 }
  25 +
  26 + @RequestMapping(value = "/getLp", method = RequestMethod.GET)
  27 + public List<Map<String,Object>> getLp(@RequestParam Map<String, Object> map){
  28 + return busIntervalService.getLp(map);
  29 + }
25 30  
26 31 @RequestMapping(value = "/interval", method = RequestMethod.GET)
27 32 public List<Map<String,Object>> interval(@RequestParam Map<String, Object> map){
... ...
src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -231,7 +231,7 @@ public class ExportController {
231 231 listI.add(resList.iterator());
232 232 String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
233 233 ee.excelReplace(listI, new Object[] { map }, path + "mould\\vehicleloading.xls",
234   - path + "export\\车辆加注" + sdfSimple.format(sdfMonth.parse(map.get("dat").toString())) + ".xls");
  234 + path + "export\\车辆加注" + sdfSimple.format(sdfMonth.parse(map.get("data").toString())) + ".xls");
235 235 } catch (Exception e) {
236 236 e.printStackTrace();
237 237 }
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -131,13 +131,13 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
131 131 * @Title: adjust @Description: TODO(调整人车) @param @param id
132 132 * 班次ID @param @param nbbm 内部编码 @param @param jsy 驾驶员 @param @param spy
133 133 * 售票员 @throws
134   - */
  134 +
135 135 @RequestMapping(value = "/adjust", method = RequestMethod.POST)
136 136 public Map<String, Object> adjust(@RequestParam Long id, String nbbm, String jsy,
137 137 String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {
138 138 return scheduleRealInfoService.adjust(id, nbbm, jsy, spy, revertLine, borrowLine, borrowTimeStr, revertTimeStr);
139 139 }
140   -
  140 + */
141 141 /**
142 142 *
143 143 * @Title: realOutAdjust
... ...
src/main/java/com/bsth/data/BasicData.java
1 1 package com.bsth.data;
2 2  
3 3 import com.bsth.Application;
4   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
5 5 import com.bsth.entity.*;
6 6 import com.bsth.entity.schedule.CarConfigInfo;
7 7 import com.bsth.repository.*;
... ...
src/main/java/com/bsth/data/LineConfigData.java
1 1 package com.bsth.data;
2 2  
3   -import java.util.Collection;
4   -import java.util.HashMap;
5   -import java.util.Iterator;
6   -import java.util.Map;
7   -import java.util.Set;
8   -
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.factory.annotation.Autowired;
12   -import org.springframework.boot.CommandLineRunner;
13   -import org.springframework.stereotype.Component;
14   -
15 3 import com.bsth.entity.Line;
16 4 import com.bsth.entity.realcontrol.D80ReplyTemp;
17 5 import com.bsth.entity.realcontrol.LineConfig;
18 6 import com.bsth.oplog.normal.OpLogger;
19 7 import com.bsth.service.LineService;
20 8 import com.bsth.service.realcontrol.LineConfigService;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.boot.CommandLineRunner;
  13 +import org.springframework.stereotype.Component;
  14 +
  15 +import java.util.*;
21 16  
22 17 /**
23 18 *
... ... @@ -92,7 +87,7 @@ public class LineConfigData implements CommandLineRunner {
92 87 //出场时间类型
93 88 conf.setOutConfig(1);
94 89 //进场时间类型
95   - conf.setInConfig(1);
  90 + //conf.setInConfig(1);
96 91 //短语模板
97 92 conf.setPhraseTemps("");
98 93 //调度指令模板
... ...
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
1 1 package com.bsth.data.gpsdata;
2 2  
3   -import com.bsth.data.gpsdata.analyse.StationRoute;
  3 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
4 4 import com.fasterxml.jackson.annotation.JsonIgnore;
5 5  
6 6 /**
... ... @@ -78,15 +78,15 @@ public class GpsEntity {
78 78 private boolean sEPoint;
79 79 */
80 80  
81   - /** 站内 */
82   - private boolean instation;
  81 + /** 0: 站外 1:站内 2:场内 */
  82 + private int instation;
83 83  
84 84 /** 站点信息,站内时有值 */
85 85 @JsonIgnore
86 86 private StationRoute station;
87 87  
88 88 /** 状态 */
89   - private String state2;
  89 + private String signalState;
90 90  
91 91 public Integer getCompanyCode() {
92 92 return companyCode;
... ... @@ -233,14 +233,6 @@ public class GpsEntity {
233 233 this.version = version;
234 234 }
235 235  
236   - public boolean isInstation() {
237   - return instation;
238   - }
239   -
240   - public void setInstation(boolean instation) {
241   - this.instation = instation;
242   - }
243   -
244 236 public StationRoute getStation() {
245 237 return station;
246 238 }
... ... @@ -257,11 +249,19 @@ public class GpsEntity {
257 249 this.abnormal = abnormal;
258 250 }
259 251  
260   - public String getState2() {
261   - return state2;
  252 + public String getSignalState() {
  253 + return signalState;
262 254 }
263 255  
264   - public void setState2(String state2) {
265   - this.state2 = state2;
  256 + public void setSignalState(String signalState) {
  257 + this.signalState = signalState;
  258 + }
  259 +
  260 + public int getInstation() {
  261 + return instation;
  262 + }
  263 +
  264 + public void setInstation(int instation) {
  265 + this.instation = instation;
266 266 }
267 267 }
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
5 5 import com.bsth.Application;
6 6 import com.bsth.data.BasicData;
7 7 import com.bsth.data.forecast.ForecastRealServer;
8   -import com.bsth.data.gpsdata.analyse.GpsAnalyse;
  8 +import com.bsth.data.gpsdata.arrival.GpsRealAnalyse;
9 9 import com.bsth.data.gpsdata.recovery.GpsDataRecovery;
10 10 import com.bsth.data.schedule.DayOfSchedule;
11 11 import com.bsth.entity.realcontrol.ScheduleRealInfo;
... ... @@ -29,256 +29,187 @@ import java.util.*;
29 29 import java.util.concurrent.TimeUnit;
30 30  
31 31 /**
32   - *
  32 + * @author PanZhao
33 33 * @ClassName: GpsRealData
34 34 * @Description: TODO(实时GPS数据集合)
35   - * @author PanZhao
36 35 * @date 2016年8月12日 下午2:04:41
37   - *
38 36 */
39 37 @Component
40   -public class GpsRealData implements CommandLineRunner{
41   -
42   - static Logger logger = LoggerFactory.getLogger(GpsRealData.class);
43   -
44   - private static Map<String, GpsEntity> gpsMap;
45   -
46   - //按线路分组设备号
47   - private static TreeMultimap<String, String> lineCode2Devices;
48   -
49   - // 网关数据接口地址
50   - private static String url;
51   -
52   - @Autowired
53   - GpsDataLoader gpsDataLoader;
54   -
55   - @Autowired
56   - DayOfSchedule dayOfSchedule;
57   -
58   - @Autowired
59   - ForecastRealServer forecastRealServer;
60   -
61   -
62   -
63   - /**
64   - * 构造函数
65   - */
66   - public GpsRealData(){
67   - gpsMap = new HashMap<>();
68   - lineCode2Devices = TreeMultimap.create();
69   - url = ConfigUtil.get("http.gps.real.url");
70   - }
71   -
72   - @Override
73   - public void run(String... arg0) throws Exception {
74   - logger.info("gpsDataLoader,20,6");
75   - Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 40, 20, TimeUnit.SECONDS);
76   - }
77   -
78   - public GpsEntity add(GpsEntity gps) {
79   - String device = gps.getDeviceId();
80   - GpsEntity old = gpsMap.get(device);
81   -
82   - //分析gps
83   - if(isAvailable(gps) && (old == null || old.getTimestamp() != gps.getTimestamp()))
84   - GpsAnalyse.start(gps);
85   -
86   - if(!StringUtils.isEmpty(gps.getStopNo())){
87   - //定时定距数据附带站点编码改变
88   - if(null == old || !gps.getStopNo().equals(old.getStopNo())){
89   - gps.setArrTime(gps.getTimestamp());
90   - //预测到达终点时间
91   - forecastRealServer.forecast(gps.getNbbm(), gps);
92   - }
93   - else{
94   - gps.setArrTime(old.getArrTime());
95   - //不预测, 重新计算终点时间
96   - gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm()));
97   - }
98   - }
99   -
100   - gpsMap.put(device, gps);
101   - if(StringUtils.isNotBlank(gps.getLineId()))
102   - lineCode2Devices.put(gps.getLineId(), device);
103   - return gps;
104   - }
105   -
106   - public boolean isAvailable(GpsEntity gps){
107   - return StringUtils.isNotEmpty(gps.getLineId()) &&
108   - dayOfSchedule.getCurrSchDate().containsKey(gps.getLineId());
109   - }
110   -
111   - /**
112   - *
113   - * @Title: get @Description: TODO(设备号获取GPS)
114   - */
115   - public GpsEntity get(String deviceId) {
116   - return gpsMap.get(deviceId);
117   - }
118   -
119   - /**
120   - *
121   - * @Title: get @Description: TODO(线路编码获取GPS集合) @throws
122   - */
123   - public List<GpsEntity> getByLine(String lineCode) {
124   - NavigableSet<String> set = lineCode2Devices.get(lineCode);
125   -
126   - List<GpsEntity> rs = new ArrayList<>();
127   - GpsEntity gps;
128   - ScheduleRealInfo sch;
129   - for(String device : set){
130   - gps = gpsMap.get(device);
131   - //过滤异常GPS数据
132   - if(gps.isAbnormal())
133   - continue;
134   -
135   - sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
136   - if(null != sch)
137   - gps.setSchId(sch.getId());
138   - rs.add(gps);
139   - }
140   -
141   - return rs;
142   - }
143   -
144   - public List<GpsEntity> get(List<String> pArray){
145   - List<GpsEntity> list = new ArrayList<>();
146   -
147   - for(String code : pArray)
148   - list.addAll(getByLine(code));
149   - return list;
150   - }
151   -
152   - public Set<String> allDevices(){
153   - return gpsMap.keySet();
154   - }
155   -
156   - public GpsEntity findByDeviceId(String deviceId) {
157   - return gpsMap.get(deviceId);
158   - }
159   -
160   - public Collection<GpsEntity> all(){
161   - return gpsMap.values();
162   - }
163   -
164   - public void remove(String device){
165   - gpsMap.remove(device);
166   - }
167   - @Component
168   - public static class GpsDataLoader extends Thread{
169   -
170   - Logger logger = LoggerFactory.getLogger(GpsDataLoader.class);
171   -
172   - @Autowired
173   - GpsRealData gpsRealData;
174   -
175   - @Override
176   - public void run() {
177   - try{
178   - //如果正在恢复数据
179   - if(GpsDataRecovery.run){
180   - return;
181   - }
182   -
183   - load();
184   - }catch(Exception e){
185   - logger.error("", e);
186   - }
187   - }
188   -
189   - public void load() throws Exception {
190   - List<GpsEntity> list = new ArrayList<>();
191   - CloseableHttpClient httpClient = null;
192   - CloseableHttpResponse response = null;
193   - try {
194   - httpClient = HttpClients.createDefault();
195   - HttpGet get = new HttpGet(url);
196   -
197   - response = httpClient.execute(get);
198   -
199   - HttpEntity entity = response.getEntity();
200   - if (null != entity) {
201   - // 返回数据量比较大,建议以流的形式读取
202   - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
203   - StringBuffer stringBuffer = new StringBuffer();
204   - String str = "";
205   - while ((str = br.readLine()) != null)
206   - stringBuffer.append(str);
207   -
208   - JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
209   -
210   - if (jsonObj != null)
211   - list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
212   -
213   - String nbbm;
214   - for(GpsEntity gps : list){
215   - //没有设备号
216   - if(StringUtils.isBlank(gps.getDeviceId()))
217   - continue;
218   -
219   - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
220   - if(StringUtils.isBlank(nbbm))
221   - gps.setAbnormal(true);//标记为异常数据
222   - else
223   - gps.setNbbm(nbbm);
224   -
225   - gps.setStationName(BasicData.stationCode2NameMap.get(gps.getStopNo()));
226   - gpsRealData.add(gps);
227   -
228   - //纠正走向
229   - //correctUpdown(gps);
230   - }
231   - } else
232   - logger.error("result is null");
233   - } catch(Exception e){
234   - logger.error("", e);
235   - }
236   - finally {
237   - if (null != httpClient)
238   - httpClient.close();
239   - if(null != response)
240   - response.close();
241   - }
242   - }
243   -
244   - /**
245   - * 是否是起终点
246   - * @param gps
247   - * @return
248   -
249   - public boolean isSEPoint(GpsEntity gps){
250   - String key = gps.getLineId()+"_"+gps.getUpDown()+"_"
251   - ,stationCode;
252   -
253   - if(BasicData.lineSEPointMap.containsKey(key+"B")){
254   - stationCode = BasicData.lineSEPointMap.get(key+"B");
255   - if(gps.getStopNo().equals(stationCode)){
256   - gps.setsEPoint(true);
257   - return true;
258   - }
259   - }
260   -
261   - if(BasicData.lineSEPointMap.containsKey(key+"E")){
262   - stationCode = BasicData.lineSEPointMap.get(key+"E");
263   - if(gps.getStopNo().equals(stationCode)){
264   - gps.setsEPoint(true);
265   - return true;
266   - }
267   - }
268   - return false;
269   - }*/
270   -
271   - /**
272   - * 纠正上下行
273   - * @param gps
274   -
275   - public void correctUpdown(GpsEntity gps){
276   - Integer updown=BasicData.lineStationUpDownMap.get(gps.getLineId()+"_"+gps.getStopNo());
277   - if(updown != null && !updown.equals(gps.getUpDown()))
278   - gps.setUpDown(updown);
279   -
280   - if(isSEPoint(gps))
281   - return;
282   - }*/
283   - }
  38 +public class GpsRealData implements CommandLineRunner {
  39 +
  40 + static Logger logger = LoggerFactory.getLogger(GpsRealData.class);
  41 +
  42 + private static Map<String, GpsEntity> gpsMap;
  43 +
  44 + //按线路分组设备号
  45 + private static TreeMultimap<String, String> lineCode2Devices;
  46 +
  47 + // 网关数据接口地址
  48 + private static String url;
  49 +
  50 + @Autowired
  51 + GpsDataLoader gpsDataLoader;
  52 +
  53 + @Autowired
  54 + DayOfSchedule dayOfSchedule;
  55 +
  56 + @Autowired
  57 + ForecastRealServer forecastRealServer;
  58 +
  59 + /**
  60 + * 构造函数
  61 + */
  62 + public GpsRealData() {
  63 + gpsMap = new HashMap<>();
  64 + lineCode2Devices = TreeMultimap.create();
  65 + url = ConfigUtil.get("http.gps.real.url");
  66 + }
  67 +
  68 + @Override
  69 + public void run(String... arg0) throws Exception {
  70 + logger.info("gpsDataLoader,40,6");
  71 + Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 40, 6, TimeUnit.SECONDS);
  72 + }
  73 +
  74 + public void put(GpsEntity gps) {
  75 + gpsMap.put(gps.getDeviceId(), gps);
  76 + }
  77 +
  78 + /**
  79 + * @Title: get @Description: TODO(设备号获取GPS)
  80 + */
  81 + public GpsEntity get(String deviceId) {
  82 + return gpsMap.get(deviceId);
  83 + }
  84 +
  85 + /**
  86 + * @Title: get @Description: TODO(线路编码获取GPS集合) @throws
  87 + */
  88 + public List<GpsEntity> getByLine(String lineCode) {
  89 + NavigableSet<String> set = lineCode2Devices.get(lineCode);
  90 +
  91 + List<GpsEntity> rs = new ArrayList<>();
  92 + GpsEntity gps;
  93 + ScheduleRealInfo sch;
  94 + for (String device : set) {
  95 + gps = gpsMap.get(device);
  96 + //过滤异常GPS数据
  97 + if (gps.isAbnormal())
  98 + continue;
  99 +
  100 + sch = dayOfSchedule.execPlanMap().get(gps.getNbbm());
  101 + if (null != sch)
  102 + gps.setSchId(sch.getId());
  103 + rs.add(gps);
  104 + }
  105 +
  106 + return rs;
  107 + }
  108 +
  109 + public List<GpsEntity> get(List<String> pArray) {
  110 + List<GpsEntity> list = new ArrayList<>();
  111 +
  112 + for (String code : pArray)
  113 + list.addAll(getByLine(code));
  114 + return list;
  115 + }
  116 +
  117 + public Set<String> allDevices() {
  118 + return gpsMap.keySet();
  119 + }
  120 +
  121 + public GpsEntity findByDeviceId(String deviceId) {
  122 + return gpsMap.get(deviceId);
  123 + }
  124 +
  125 + public Collection<GpsEntity> all() {
  126 + return gpsMap.values();
  127 + }
  128 +
  129 + public void remove(String device) {
  130 + gpsMap.remove(device);
  131 + }
  132 +
  133 + @Component
  134 + public static class GpsDataLoader extends Thread {
  135 +
  136 + Logger logger = LoggerFactory.getLogger(GpsDataLoader.class);
  137 +
  138 + @Autowired
  139 + GpsRealData gpsRealData;
  140 +
  141 + @Autowired
  142 + GpsRealAnalyse gpsRealAnalyse;
  143 +
  144 + @Override
  145 + public void run() {
  146 + try {
  147 + //如果正在恢复数据
  148 + if (GpsDataRecovery.run)
  149 + return;
  150 +
  151 + load();
  152 + } catch (Exception e) {
  153 + logger.error("", e);
  154 + }
  155 + }
  156 +
  157 + public void load() throws Exception {
  158 + List<GpsEntity> list = null;
  159 + List<GpsEntity> updateList = new ArrayList<>();
  160 + CloseableHttpClient httpClient = null;
  161 + CloseableHttpResponse response = null;
  162 + try {
  163 + httpClient = HttpClients.createDefault();
  164 + HttpGet get = new HttpGet(url);
  165 +
  166 + response = httpClient.execute(get);
  167 +
  168 + HttpEntity entity = response.getEntity();
  169 + if (null != entity) {
  170 + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
  171 + StringBuffer stringBuffer = new StringBuffer();
  172 + String str = "";
  173 + while ((str = br.readLine()) != null)
  174 + stringBuffer.append(str);
  175 +
  176 + JSONObject jsonObj = JSON.parseObject(stringBuffer.toString());
  177 +
  178 + if (jsonObj != null)
  179 + list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
  180 +
  181 + String nbbm;
  182 + GpsEntity old;
  183 + for (GpsEntity gps : list) {
  184 + //没有设备号
  185 + if (StringUtils.isBlank(gps.getDeviceId()))
  186 + continue;
  187 +
  188 + old = gpsMap.get(gps.getDeviceId());
  189 + if (old != null &&
  190 + old.getTimestamp() == gps.getTimestamp())
  191 + continue;
  192 +
  193 + nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId());
  194 + if (StringUtils.isBlank(nbbm))
  195 + gps.setAbnormal(true);//标记为异常数据
  196 + else
  197 + gps.setNbbm(nbbm);
  198 + //有更新的点位
  199 + updateList.add(gps);
  200 + }
  201 + //分析数据
  202 + gpsRealAnalyse.analyse(updateList);
  203 + } else
  204 + logger.error("real gps result is null");
  205 + } catch (Exception e) {
  206 + logger.error("", e);
  207 + } finally {
  208 + if (null != httpClient)
  209 + httpClient.close();
  210 + if (null != response)
  211 + response.close();
  212 + }
  213 + }
  214 + }
284 215 }
285 216 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/analyse/GpsAnalyse.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.analyse;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.analyse.components.GpsArrival;
5   -import org.slf4j.Logger;
6   -import org.slf4j.LoggerFactory;
7   -
8   -import java.util.concurrent.ExecutorService;
9   -import java.util.concurrent.Executors;
10   -
11   -/**
12   - * 分析gps状态信息
13   - * Created by panzhao on 2016/12/23.
14   - */
15   -public class GpsAnalyse {
16   -
17   - static Logger logger = LoggerFactory.getLogger(GpsAnalyse.class);
18   -
19   - //线程池
20   - static ExecutorService threadPool = Executors.newFixedThreadPool(50);
21   -
22   - public static void start(GpsEntity gps) {
23   - threadPool.execute(new ArrivalMatchThread(gps));
24   - }
25   -
26   - public static class ArrivalMatchThread implements Runnable {
27   -
28   - private GpsEntity gps;
29   -
30   - public ArrivalMatchThread(GpsEntity gps) {
31   - this.gps = gps;
32   - }
33   -
34   - @Override
35   - public void run() {
36   - GpsArrival.arrival(gps);
37   - }
38   - }
39   -}
40 0 \ No newline at end of file
src/main/java/com/bsth/data/gpsdata/analyse/components/GpsArrival.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.analyse.components;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.analyse.CircleQueue;
6   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
7   -import com.bsth.data.gpsdata.analyse.StationRoute;
8   -import com.bsth.data.gpsdata.analyse.util.GeoUtils;
9   -import com.bsth.data.schedule.DayOfSchedule;
10   -import com.bsth.entity.realcontrol.LineConfig;
11   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
12   -import org.slf4j.Logger;
13   -import org.slf4j.LoggerFactory;
14   -import org.springframework.beans.BeansException;
15   -import org.springframework.context.ApplicationContext;
16   -import org.springframework.context.ApplicationContextAware;
17   -import org.springframework.stereotype.Component;
18   -
19   -import java.util.List;
20   -
21   -/**
22   - * gps 到离站判断
23   - * Created by panzhao on 2016/12/24.
24   - */
25   -@Component
26   -public class GpsArrival implements ApplicationContextAware {
27   -
28   - static Logger logger = LoggerFactory.getLogger(GpsArrival.class);
29   -
30   - static DayOfSchedule dayOfSchedule;
31   -
32   - static LineConfigData lineConfigData;
33   -
34   - public static void arrival(GpsEntity gps) {
35   -
36   - if (gps.getLat() == 0 || gps.getLon() == 0) {
37   - //logger.error("无效的gps");
38   - return;
39   - }
40   -
41   - Object task = DayOfSchedule.executeCurr(gps.getNbbm());
42   - if (task == null)
43   - return;
44   - if (task.getClass().isAssignableFrom(ScheduleRealInfo.class)) {
45   - ScheduleRealInfo sch = (ScheduleRealInfo) task;
46   - //和班次同步走向
47   - gps.setUpDown(Integer.parseInt(sch.getXlDir()));
48   -
49   - //出场
50   - if (sch.getBcType().equals("out")) {
51   - outCarpark(gps, sch);
52   - }
53   - else if (sch.getBcType().equals("normal"))
54   - normalInOut(gps, sch);
55   - else if(sch.getBcType().equals("in")){
56   - inCarpark(gps, sch);
57   - }
58   - }
59   -
60   - GeoCacheData.putGps(gps);
61   - }
62   -
63   - /**
64   - * 正常班次
65   - *
66   - * @param gps
67   - * @param sch
68   - */
69   - private static void normalInOut(GpsEntity gps, ScheduleRealInfo sch) {
70   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
71   - GpsEntity prev = null;
72   - if (queue != null)
73   - prev = queue.getTail();
74   -
75   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), gps.getUpDown());
76   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
77   -
78   - if (station != null) {
79   - //站内
80   - gps.setStopNo(station.getCode());
81   - gps.setInstation(true);
82   - stationInside(gps, prev, sch);
83   - } else {
84   - //站外
85   - stationOutside(gps, prev, sch);
86   - }
87   - }
88   -
89   - /**
90   - * GPS在站点内
91   - *
92   - * @param gps
93   - * @param prev
94   - * @param sch
95   - */
96   - private static void stationInside(GpsEntity gps, GpsEntity prev, ScheduleRealInfo sch) {
97   - if(prev == null)
98   - return;
99   -
100   - if (gps.getStopNo().equals(sch.getZdzCode()) && sch.getZdsjActual() == null) {
101   - //到终点站
102   - arriveEnd(sch, gps);
103   - return;
104   - }
105   -
106   - //上一个点在站外
107   - if(!prev.isInstation())
108   - return;
109   - //超过 (待发时间 + 90%的单程运送时间),还在起点站。默认烂一圈
110   - if (prev.getStopNo().equals(gps.getStopNo())){
111   - if(gps.getStopNo().equals(sch.getQdzCode())
112   - && gps.getTimestamp() > sch.getDfsjT() + (sch.getBcsj() * 60 * 1000 * 0.9)){
113   -
114   - ScheduleRealInfo next = dayOfSchedule.next(dayOfSchedule.next(sch));
115   - dayOfSchedule.addExecPlan(next);
116   - }
117   - return;
118   - }
119   -
120   - //发车
121   - if (prev.getStopNo().equals(sch.getQdzCode())) {
122   - busWillDepart(sch, gps);
123   - return;
124   - }
125   -
126   - //中途站
127   - StationRoute prevStation = GeoCacheData.getStation(prev.getLineId(), prev.getUpDown(), prev.getStopNo());
128   - StationRoute currStation = GeoCacheData.getStation(gps.getLineId(), gps.getUpDown(), gps.getStopNo());
129   - if (currStation.getRouteSort() < prevStation.getRouteSort()) {
130   - //开始下一个班次
131   - finishPlan(sch);
132   -
133   - logger.info("路由反向。。。。。。:" + gps.getTimestamp());
134   - //为班次补上实际时间
135   -
136   - }
137   - }
138   -
139   - /**
140   - * GPS在站点外
141   - *
142   - * @param gps
143   - * @param prev
144   - * @param sch
145   - */
146   - private static void stationOutside(GpsEntity gps, GpsEntity prev, ScheduleRealInfo sch) {
147   - if(prev == null)
148   - return;
149   -
150   - gps.setStopNo(prev.getStopNo());
151   - if (prev.isInstation() && prev.getStopNo().equals(sch.getQdzCode())) {
152   - //发车
153   - busWillDepart(sch, gps);
154   - return;
155   - }
156   - }
157   -
158   - /**
159   - * 公交车起点发出
160   - */
161   - final static long DRIFT_VAL_TIME = 1000 * 60 * 10;
162   - //班次最大差值1小时
163   - final static long MAX_DIFF = 1000 * 60 * 60;
164   - private static void busWillDepart(ScheduleRealInfo sch, GpsEntity gps) {
165   - //实发时间不覆盖
166   - if (sch.getFcsjActual() == null && Math.abs(gps.getTimestamp() - sch.getDfsjT()) < MAX_DIFF) {
167   -
168   - //提前10分钟以上发出,判断一下是否是漂移
169   - if(sch.getDfsjT() - gps.getTimestamp() > DRIFT_VAL_TIME){
170   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
171   - if(schPrev != null && schPrev.getZdsjActual() != null){
172   - //计划停站时间
173   - long stopTimeJH = sch.getDfsjT() - schPrev.getZdsjT();
174   - //实际停站时间
175   - long actualStopTime = gps.getTimestamp() - schPrev.getZdsjActualTime();
176   - /*
177   - 没停够计划百分之60的,算漂移
178   - (这里出现的误判,由程序在车辆到中途站的时候进行补偿)
179   - */
180   - if(stopTimeJH * 0.6 < actualStopTime){
181   - logger.info("漂移.... 车辆:" + gps.getNbbm() + " ts: " + gps.getTimestamp());
182   - return;
183   - }
184   - }
185   - }
186   -
187   - LineConfig config = lineConfigData.get(sch.getXlBm());
188   - if(config != null && config.getOutConfig() == 2){
189   - //出站既出场
190   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
191   - if(schPrev.getBcType().equals("out")){
192   - schPrev.setFcsjActualAll(schPrev.getDfsjT());
193   - schPrev.setZdsjActualAll(schPrev.getZdsjT());
194   - }
195   - }
196   -
197   - sch.setFcsjActualAll(gps.getTimestamp());
198   - logger.info("(站外)班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
199   - }
200   - }
201   -
202   - /**
203   - * 公交车到达终点
204   - *
205   - * @param sch
206   - * @param gps
207   - */
208   - private static void arriveEnd(ScheduleRealInfo sch, GpsEntity gps) {
209   - sch.setZdsjActualAll(gps.getTimestamp());
210   - ScheduleRealInfo next = finishPlan(sch);
211   - logger.info("班次:" + sch.getDfsj() + "到达终点, 时间:" + sch.getZdsjActual());
212   -
213   - if (next == null)
214   - return;
215   -
216   - //将gps转换为下一个班次走向的站内信号
217   - int updown = Integer.parseInt(next.getXlDir());
218   - List<StationRoute> srs = GeoCacheData.getStationRoute(next.getXlBm(), updown);
219   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
220   - if (station != null) {
221   - gps.setUpDown(updown);
222   - gps.setStopNo(station.getCode());
223   - }
224   - }
225   -
226   - /**
227   - * 出场班次
228   - *
229   - * @param gps
230   - * @param sch
231   - */
232   - private static void outCarpark(GpsEntity gps, ScheduleRealInfo sch) {
233   - String carpark = GeoUtils.gpsInCarpark(gps);
234   - if (carpark != null) {
235   - gps.setInstation(true);
236   - gps.setStopNo(carpark);
237   - return; // 还在场内
238   - }
239   -
240   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
241   - if (queue == null)
242   - return;
243   - //上一个gps
244   - GpsEntity prev = queue.getTail();
245   -
246   - if (carpark == null && prev.isInstation() && prev.getStopNo().equals(sch.getQdzCode())) {
247   - gps.setStopNo(prev.getStopNo());
248   - //停车场发出
249   - busWillDepart(sch, gps);
250   - return;
251   - }
252   -
253   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), gps.getUpDown());
254   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
255   -
256   - if (station != null && station.getCode().equals(sch.getZdzCode())) {
257   - gps.setStopNo(station.getCode());
258   - //到达终点
259   - arriveEnd(sch, gps);
260   - }
261   - }
262   -
263   -
264   - /**
265   - * 进场班次
266   - * @param gps
267   - * @param sch
268   - */
269   - private static void inCarpark(GpsEntity gps, ScheduleRealInfo sch) {
270   - String carpark = GeoUtils.gpsInCarpark(gps);
271   - if (carpark != null && carpark.equals(sch.getZdzCode())) {
272   - //进场班次取第一个实际进场时间
273   - if(sch.getZdsjActual() != null)
274   - return;
275   -
276   - //进场
277   - arriveEnd(sch, gps);
278   - return;
279   - }
280   -
281   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
282   - if (queue == null)
283   - return;
284   - //上一个gps
285   - GpsEntity prev = queue.getTail();
286   -
287   - if (carpark == null && prev.isInstation() && prev.getStopNo().equals(sch.getQdzCode())) {
288   - gps.setStopNo(prev.getStopNo());
289   - //进场班次发出
290   - busWillDepart(sch, gps);
291   - return;
292   - }
293   - }
294   -
295   - /**
296   - * 完成班次 -返回下一个班次
297   - *
298   - * @param sch
299   - */
300   - private static ScheduleRealInfo finishPlan(ScheduleRealInfo sch) {
301   - ScheduleRealInfo next = dayOfSchedule.next(sch);
302   - if (next != null) {
303   - next.setQdzArrDatesj(sch.getZdsjActual());
304   - dayOfSchedule.addExecPlan(next);
305   - }
306   - return next;
307   - }
308   -
309   - @Override
310   - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
311   - dayOfSchedule = applicationContext.getBean(DayOfSchedule.class);
312   - lineConfigData = applicationContext.getBean(LineConfigData.class);
313   - }
314   -}
src/main/java/com/bsth/data/gpsdata/analyse/components/GpsStateCorrective.java deleted 100644 → 0
1   -package com.bsth.data.gpsdata.analyse.components;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.schedule.DayOfSchedule;
5   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
6   -import com.vividsolutions.jts.geom.GeometryFactory;
7   -import org.joda.time.format.DateTimeFormat;
8   -import org.joda.time.format.DateTimeFormatter;
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.BeansException;
12   -import org.springframework.context.ApplicationContext;
13   -import org.springframework.context.ApplicationContextAware;
14   -import org.springframework.stereotype.Component;
15   -
16   -/**
17   - * GPS状态纠正
18   - * Created by panzhao on 2016/12/23.
19   - */
20   -@Component
21   -public class GpsStateCorrective implements ApplicationContextAware {
22   -
23   - static Logger logger = LoggerFactory.getLogger(GpsStateCorrective.class);
24   -
25   - static DayOfSchedule dayOfSchedule;
26   -
27   - private static GeometryFactory geometryFactory = new GeometryFactory();
28   -
29   - public static void correct(GpsEntity gps, ScheduleRealInfo sch){
30   -/* int upDown = Integer.parseInt(sch.getXlDir());
31   - gps.setUpDown(upDown);
32   - List<StationRoute> srs = GeoCacheData.getStationRoute(sch.getXlBm(), upDown);
33   -
34   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
35   -
36   - //之前的点位
37   - CircleQueue<GpsEntity> queue = GeoCacheData.getGps(gps.getNbbm());
38   - GpsEntity prev = null;
39   - if(queue != null)
40   - prev = queue.getTail();
41   -
42   - //线路上,站点间
43   - StationRoute station = GeoUtils.pointInStation(point, srs);
44   - //在站内
45   - if(station != null){
46   - gps.setStopNo(station.getCode());
47   - gps.setInstation(true);
48   - gps.setStation(station);
49   -
50   - if(prev != null && prev.getUpDown() == upDown){
51   - StationRoute prevStation = GeoCacheData.getStation(prev.getLineId(), upDown, prev.getStopNo());
52   -
53   - //倒着开??
54   - if(prevStation.getRouteSort() > station.getRouteSort()){
55   - reversalHandle(gps, prev, sch);
56   - }
57   - }
58   - }
59   - else{
60   - if(prev != null)
61   - gps.setStopNo(prev.getStopNo());
62   - }
63   -
64   - //是否在停车场内
65   - Map<String, Polygon> carparkMap = GeoCacheData.tccMap;
66   - Set<String> codes = carparkMap.keySet();
67   - Polygon p;
68   - for(String code : codes){
69   - p = carparkMap.get(code);
70   - //场内
71   - if(p.contains(point)){
72   - gps.setCarparkNo(code);
73   - if(sch.getBcType().equals("out")){
74   - gps.setInstation(true);
75   - gps.setStopNo(code);
76   - }
77   - }
78   - }*/
79   - }
80   -
81   - private static DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm");
82   -
83   - private static void reversalHandle(GpsEntity gps, GpsEntity prev, ScheduleRealInfo sch){
84   - /*if(sch.getBcType().equals("out") && gps.getTimestamp() < sch.getZdsjT())
85   - return;
86   -
87   - //先假设没到终点,直接开始了下一个班次
88   - ScheduleRealInfo next = dayOfSchedule.next(sch);
89   - String log = "倒着开??? nbbm: " + gps.getNbbm() + " 当前:" + gps.getStopNo() + " 上一站:" + prev.getStopNo() + " 当前班次:" + sch.getDfsj();
90   - if(next != null){
91   - dayOfSchedule.addExecPlan(next);
92   -
93   - log += (" 下一个班次:" + next.getDfsj());
94   - }
95   -
96   - log += (" GPS时间:" + fmt.print(gps.getTimestamp()));
97   -
98   - logger.info(log);*/
99   - }
100   -
101   - @Override
102   - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
103   - dayOfSchedule = applicationContext.getBean(DayOfSchedule.class);
104   - }
105   -}
src/main/java/com/bsth/data/gpsdata/analyse/GeoCacheData.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival;
2 2  
3 3 import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
4 7 import com.google.common.collect.ArrayListMultimap;
5 8 import com.vividsolutions.jts.geom.Coordinate;
6 9 import com.vividsolutions.jts.geom.GeometryFactory;
... ... @@ -26,8 +29,8 @@ public class GeoCacheData {
26 29  
27 30 static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
28 31  
29   - //每辆车缓存最后200条gps
30   - private static final int CACHE_SIZE = 200;
  32 + //每辆车缓存最后500条gps
  33 + private static final int CACHE_SIZE = 500;
31 34 private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
32 35  
33 36 //线路路段走向
... ... @@ -36,6 +39,9 @@ public class GeoCacheData {
36 39 //线路站点路由
37 40 private static ArrayListMultimap<String, StationRoute> stationCacheMap;
38 41  
  42 + //线路_上下行_站点编码 ——> 站点
  43 + private static Map<String, StationRoute> routeCodeMap;
  44 +
39 45 //停车场
40 46 public static Map<String, Polygon> tccMap;
41 47  
... ... @@ -49,9 +55,9 @@ public class GeoCacheData {
49 55 public static void putGps(GpsEntity gps) {
50 56 CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
51 57 if (queue == null) {
52   - //第一个点从站内开始
53   - if(!gps.isInstation())
54   - return;
  58 + /*//第一个点从站内开始
  59 + if (gps.getInstation() == 0)
  60 + return;*/
55 61  
56 62 queue = new CircleQueue<>(CACHE_SIZE);
57 63 gpsCacheMap.put(gps.getNbbm(), queue);
... ... @@ -59,6 +65,20 @@ public class GeoCacheData {
59 65 queue.add(gps);
60 66 }
61 67  
  68 + public static void clear(String nbbm) {
  69 + try {
  70 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
  71 + if (queue != null)
  72 + queue.clear();
  73 + } catch (Exception e) {
  74 + logger.error("", e);
  75 + }
  76 + }
  77 +
  78 + public static StationRoute getRouteCode(GpsEntity gps){
  79 + return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
  80 + }
  81 +
62 82 public static List<StationRoute> getStationRoute(String lineCode, int directions) {
63 83 return stationCacheMap.get(lineCode + "_" + directions);
64 84 }
... ... @@ -74,14 +94,14 @@ public class GeoCacheData {
74 94 return null;
75 95 }
76 96  
77   - public static Polygon getTccPolygon(String code){
  97 + public static Polygon getTccPolygon(String code) {
78 98 return tccMap.get(code);
79 99 }
80 100  
81 101 public void loadData() {
82 102 final GeometryFactory geometryFactory = new GeometryFactory();
83 103 //加载站点路由
84   - String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code";
  104 + 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";
85 105 List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
86 106 @Override
87 107 public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
... ... @@ -93,11 +113,12 @@ public class GeoCacheData {
93 113 sRoute.setRadius(rs.getFloat("RADIUS"));
94 114 sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
95 115 sRoute.setMark(rs.getString("STATION_MARK"));
  116 + sRoute.setName(rs.getString("STATION_NAME"));
96 117  
97 118 String shapesType = rs.getString("SHAPES_TYPE");
98 119 //多边形电子围栏
99 120 if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
100   - geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID")));
  121 + sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
101 122 }
102 123 return sRoute;
103 124 }
... ... @@ -105,8 +126,11 @@ public class GeoCacheData {
105 126 //按线路和走向分组
106 127 if (routeList.size() > 0) {
107 128 ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
  129 + Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
108 130 for (StationRoute sr : routeList) {
109 131 tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
  132 + //站点编码 ——> 和路由顺序对照
  133 + codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
110 134 }
111 135  
112 136 StationRouteComp srCom = new StationRouteComp();
... ... @@ -118,6 +142,7 @@ public class GeoCacheData {
118 142 }
119 143  
120 144 stationCacheMap = tempMap;
  145 + routeCodeMap = codeMap;
121 146 }
122 147  
123 148 //加载停车场数据
... ... @@ -133,11 +158,11 @@ public class GeoCacheData {
133 158 tccTempMap.put(tMap.get("PARK_CODE").toString()
134 159 , polygon);
135 160 } catch (Exception e) {
136   - logger.error("停车场:" + tMap.get("PARK_CODE") , e);
  161 + logger.error("停车场:" + tMap.get("PARK_CODE"), e);
137 162 }
138 163 }
139 164  
140   - if(tccTempMap.size() > 0)
  165 + if (tccTempMap.size() > 0)
141 166 tccMap = tccTempMap;
142 167 }
143 168  
... ... @@ -166,5 +191,4 @@ public class GeoCacheData {
166 191 }
167 192 return cds;
168 193 }
169   -
170 194 }
171 195 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.handlers.*;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +import java.util.concurrent.CountDownLatch;
  13 +import java.util.concurrent.ExecutorService;
  14 +import java.util.concurrent.Executors;
  15 +
  16 +/**
  17 + * gps 实时数据分析
  18 + * Created by panzhao on 2016/12/27.
  19 + */
  20 +@Component
  21 +public class GpsRealAnalyse {
  22 +
  23 + Logger logger = LoggerFactory.getLogger(this.getClass());
  24 +
  25 + @Autowired
  26 + OfflineSignalHandle offlineSignalHandle;
  27 + @Autowired
  28 + CorrectSignalHandle correctSignalHandle;
  29 + @Autowired
  30 + StationInsideHandle stationInsideHandle;
  31 + @Autowired
  32 + InOutStationSignalHandle inOutStationSignalHandle;
  33 + @Autowired
  34 + ReverseSignalHandle reverseSignalHandle;
  35 +
  36 + //50个线程
  37 + static ExecutorService threadPool = Executors.newFixedThreadPool(50);
  38 +
  39 + public void analyse(List<GpsEntity> list) {
  40 + CountDownLatch count = new CountDownLatch(list.size());
  41 +
  42 + for(GpsEntity gps : list)
  43 + threadPool.execute(new SignalHandleThread(gps, count));
  44 +
  45 + try {
  46 + //等待子线程结束
  47 + count.await();
  48 + } catch (InterruptedException e) {
  49 + logger.error("", e);
  50 + }
  51 + }
  52 +
  53 + public class SignalHandleThread implements Runnable {
  54 +
  55 + GpsEntity gps;
  56 + CountDownLatch count;
  57 +
  58 + SignalHandleThread(GpsEntity gps, CountDownLatch count) {
  59 + this.gps = gps;
  60 + this.count = count;
  61 + }
  62 +
  63 + @Override
  64 + public void run() {
  65 +
  66 + try {
  67 + CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm());
  68 + //掉线处理
  69 + offlineSignalHandle.handle(gps, prevs);
  70 + //状态处理
  71 + if(!correctSignalHandle.handle(gps, prevs))
  72 + return;
  73 + //场,站内外判断
  74 + stationInsideHandle.handle(gps, prevs);
  75 + //反向处理
  76 + reverseSignalHandle.handle(gps, prevs);
  77 + //进出站动作处理
  78 + inOutStationSignalHandle.handle(gps, prevs);
  79 + GeoCacheData.putGps(gps);
  80 +
  81 + } catch (Exception e) {
  82 + logger.error("", e);
  83 + } finally {
  84 + count.countDown();
  85 + }
  86 + }
  87 + }
  88 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  5 +
  6 +/**
  7 + * Created by panzhao on 2016/12/27.
  8 + */
  9 +public abstract class SignalHandle {
  10 +
  11 + public abstract boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs);
  12 +
  13 + protected boolean isNotEmpty(CircleQueue<GpsEntity> prevs) {
  14 + return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
  15 + }
  16 +
  17 + /**
  18 + * 是不是异常信号
  19 + *
  20 + * @param gps
  21 + * @return
  22 + */
  23 + protected boolean isAbnormal(GpsEntity gps) {
  24 + return gps.getLat() == 0 || gps.getLon() == 0;
  25 + }
  26 +
  27 + /**
  28 + * 连续异常信号个数统计
  29 + *
  30 + * @param prevs
  31 + * @return
  32 + */
  33 + protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
  34 + int count = 0;
  35 +
  36 + if (!isNotEmpty(prevs))
  37 + return count;
  38 +
  39 + GpsEntity[] array = (GpsEntity[]) prevs.getQueue();
  40 + GpsEntity gps;
  41 + for (int i = array.length - 1; i > 0; i--) {
  42 + gps = array[i];
  43 +
  44 + if (isAbnormal(gps))
  45 + count++;
  46 + else
  47 + break;
  48 + }
  49 +
  50 + return count;
  51 + }
  52 +
  53 + /**
  54 + * 车辆运行轨迹(最近20分钟)
  55 + * 0:上行 1:下行 -1:未知
  56 + *
  57 + * @param gps
  58 + * @return
  59 + */
  60 + protected int runTrack(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  61 + int rs = -1, count = 0;
  62 +
  63 + long et = gps.getTimestamp() - (1000 * 60 * 20);
  64 + Object[] array = prevs.getQueue();
  65 + GpsEntity prev;
  66 + for(Object obj : array){
  67 + prev = (GpsEntity) obj;
  68 + if(prev.getTimestamp() < et)
  69 + break;
  70 +
  71 +
  72 + }
  73 + //for()
  74 + return 0;
  75 + }
  76 +
  77 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/RouteReverse.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +/** 路由反转
  4 + * Created by panzhao on 2016/12/28.
  5 + */
  6 +public class RouteReverse {
  7 +
  8 + //反转个数
  9 + private int count;
  10 +
  11 + //详细 1,2,3,2,1
  12 + private String detail;
  13 +
  14 + //掉头站点
  15 + private String turned;
  16 +
  17 + //开始时间
  18 + private long st;
  19 +
  20 + //掉头时间
  21 + private long zt;
  22 +
  23 + //结束时间
  24 + private long et;
  25 +
  26 + //是否闭合
  27 + private boolean close;
  28 +
  29 + public int getCount() {
  30 + return count;
  31 + }
  32 +
  33 + public void setCount(int count) {
  34 + this.count = count;
  35 + }
  36 +
  37 + public String getDetail() {
  38 + return detail;
  39 + }
  40 +
  41 + public void setDetail(String detail) {
  42 + this.detail = detail;
  43 + }
  44 +
  45 + public String getTurned() {
  46 + return turned;
  47 + }
  48 +
  49 + public void setTurned(String turned) {
  50 + this.turned = turned;
  51 + }
  52 +
  53 + public long getSt() {
  54 + return st;
  55 + }
  56 +
  57 + public void setSt(long st) {
  58 + this.st = st;
  59 + }
  60 +
  61 + public long getEt() {
  62 + return et;
  63 + }
  64 +
  65 + public void setEt(long et) {
  66 + this.et = et;
  67 + }
  68 +
  69 + public boolean isClose() {
  70 + return close;
  71 + }
  72 +
  73 + public void setClose(boolean close) {
  74 + this.close = close;
  75 + }
  76 +
  77 + public long getZt() {
  78 + return zt;
  79 + }
  80 +
  81 + public void setZt(long zt) {
  82 + this.zt = zt;
  83 + }
  84 +}
... ...
src/main/java/com/bsth/data/gpsdata/analyse/StationRoute.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/entity/StationRoute.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival.entity;
2 2  
3 3 import com.vividsolutions.jts.geom.Point;
4 4 import com.vividsolutions.jts.geom.Polygon;
... ... @@ -58,6 +58,8 @@ public class StationRoute {
58 58 */
59 59 private StationRoute prve;
60 60  
  61 + private String name;
  62 +
61 63 public String getCode() {
62 64 return code;
63 65 }
... ... @@ -137,5 +139,13 @@ public class StationRoute {
137 139 public void setMark(String mark) {
138 140 this.mark = mark;
139 141 }
  142 +
  143 + public String getName() {
  144 + return name;
  145 + }
  146 +
  147 + public void setName(String name) {
  148 + this.name = name;
  149 + }
140 150 }
141 151  
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.schedule.DayOfSchedule;
  7 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  8 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +/**
  13 + * 信号状态纠正
  14 + * Created by panzhao on 2016/12/27.
  15 + */
  16 +@Component
  17 +public class CorrectSignalHandle extends SignalHandle {
  18 +
  19 + @Autowired
  20 + DayOfSchedule dayOfSchedule;
  21 +
  22 + @Override
  23 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  24 + Object task = dayOfSchedule.executeCurr(gps.getNbbm());
  25 + if(task == null)
  26 + return false;
  27 + ScheduleRealInfo sch;
  28 +
  29 + //子任务
  30 + if(task.getClass().isAssignableFrom(ChildTaskPlan.class)){
  31 + ChildTaskPlan childTask = (ChildTaskPlan) task;
  32 + sch = childTask.getSchedule();
  33 + }
  34 + else
  35 + sch = (ScheduleRealInfo) task;
  36 +
  37 + int updown = Integer.parseInt(sch.getXlDir());
  38 + //走向
  39 + if(gps.getUpDown() != updown){
  40 + gps.setUpDown(updown);
  41 + gps.setState(0);
  42 + }
  43 +
  44 +
  45 + return true;
  46 + }
  47 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  6 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  7 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  8 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  9 +import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  10 +import com.bsth.data.schedule.DayOfSchedule;
  11 +import com.bsth.entity.realcontrol.LineConfig;
  12 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  13 +import com.bsth.service.directive.DirectiveService;
  14 +import com.bsth.websocket.handler.SendUtils;
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.util.List;
  21 +
  22 +/**
  23 + * 进出站动作处理
  24 + * Created by panzhao on 2016/12/27.
  25 + */
  26 +@Component
  27 +public class InOutStationSignalHandle extends SignalHandle{
  28 +
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + @Autowired
  32 + DayOfSchedule dayOfSchedule;
  33 +
  34 + @Autowired
  35 + LineConfigData lineConfigData;
  36 +
  37 + @Autowired
  38 + SendUtils sendUtils;
  39 +
  40 + @Autowired
  41 + DirectiveService directiveService;
  42 +
  43 + @Override
  44 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  45 +
  46 + if(isNotEmpty(prevs)){
  47 + GpsEntity prev = prevs.getTail();
  48 + if(isOutStation(gps, prev))
  49 + outStation(gps, prev);
  50 +
  51 +
  52 + if(isInStation(gps, prev))
  53 + inStation(gps, prev);
  54 + }
  55 +
  56 + return true;
  57 + }
  58 +
  59 + private boolean isOutStation(GpsEntity gps, GpsEntity prev){
  60 + //从站内到站外
  61 + if(prev.getInstation() > 0 && gps.getInstation() == 0)
  62 + return true;
  63 +
  64 + //从站内到另一个站内
  65 + if(prev.getInstation() > 0 && gps.getInstation() > 0
  66 + && !prev.getStopNo().equals(gps.getStopNo()))
  67 + return true;
  68 + return false;
  69 + }
  70 +
  71 + private boolean isInStation(GpsEntity gps, GpsEntity prev){
  72 + //从站外到站内
  73 + if(prev.getInstation() == 0 && gps.getInstation() > 0
  74 + /*&& !prev.getStopNo().equals(gps.getStopNo())*/){
  75 + return true;
  76 + }
  77 +
  78 + //从站内到另一个站内
  79 + if(prev.getInstation() > 0 && gps.getInstation() > 0
  80 + && !prev.getStopNo().equals(gps.getStopNo()))
  81 + return true;
  82 + return false;
  83 + }
  84 +
  85 + /**
  86 + * 出站
  87 + * @param gps 当前点
  88 + * @param prev 上一个点
  89 + */
  90 + private void outStation(GpsEntity gps, GpsEntity prev) {
  91 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  92 + String qdzCode = sch.getQdzCode();
  93 +
  94 +
  95 + //if(sch.getFcsjActual() != )
  96 +
  97 + //起点发车
  98 + if(qdzCode != null && prev.getStopNo().equals(qdzCode)
  99 + && !willDepart(gps, prev, sch)){
  100 +
  101 + sch.setFcsjActualAll(gps.getTimestamp());
  102 + //通知客户端
  103 + sendUtils.sendFcsj(sch);
  104 + //持久化
  105 + dayOfSchedule.save(sch);
  106 +
  107 + //出站既出场
  108 + outStationAndOutPark(sch);
  109 + logger.info("班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
  110 + }
  111 + }
  112 +
  113 + private void outStationAndOutPark(ScheduleRealInfo sch){
  114 + LineConfig config = lineConfigData.get(sch.getXlBm());
  115 + if (config != null && config.getOutConfig() == 2) {
  116 + //出站既出场
  117 + ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
  118 + if (schPrev != null && schPrev.getBcType().equals("out")) {
  119 + schPrev.setFcsjActualAll(sch.getFcsjActual());
  120 + schPrev.setZdsjActualAll(sch.getFcsjActual());
  121 + }
  122 + }
  123 + }
  124 +
  125 + /**
  126 + * 进站
  127 + * @param gps 当前点
  128 + * @param prev 上一个点
  129 + */
  130 + private void inStation(GpsEntity gps, GpsEntity prev){
  131 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  132 + String zdzCode = sch.getZdzCode();
  133 +
  134 + if(zdzCode != null && gps.getStopNo().equals(zdzCode)){
  135 +
  136 + sch.setZdsjActualAll(gps.getTimestamp());
  137 + //已完成班次数
  138 + int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
  139 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  140 + //通知客户端
  141 + sendUtils.sendZdsj(sch, next, doneSum);
  142 + //持久化
  143 + dayOfSchedule.save(sch);
  144 + //下发调度指令
  145 + //directiveService.send60Dispatch(next, doneSum, "到站@系统");
  146 +
  147 + //准备执行下一个班次
  148 + if (next != null) {
  149 + next.setQdzArrDatesj(sch.getZdsjActual());
  150 + dayOfSchedule.addExecPlan(next);
  151 +
  152 + //进站既进场
  153 + inStationAndInPark(sch, next);
  154 +
  155 + //将gps转换为下一个班次走向的站内信号
  156 + int updown = Integer.parseInt(next.getXlDir());
  157 + List<StationRoute> srs = GeoCacheData.getStationRoute(next.getXlBm(), updown);
  158 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  159 + if (station != null) {
  160 + gps.setUpDown(updown);
  161 + gps.setStopNo(station.getCode());
  162 + }
  163 + }
  164 + }
  165 + /* //如果出场班次计划终点时间5分钟后还未完成,检查一下车辆轨迹,是否已经在执行线路上班次
  166 + else if(sch.getBcType().equals("out")
  167 + && sch.getZdsj() != null
  168 + && gps.getTimestamp() - sch.getZdsjT() >= 1000 * 60 * 5){
  169 + logger.info("出场班次计划终点时间5分钟后还未完成");
  170 +
  171 + }*/
  172 + }
  173 +
  174 + /**
  175 + * 进站既进场
  176 + * @param sch
  177 + */
  178 + private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
  179 + LineConfig config = lineConfigData.get(sch.getXlBm());
  180 + if (next.getBcType().equals("in") &&
  181 + config != null && config.getOutConfig() == 2) {
  182 + next.setFcsjActualAll(sch.getZdsjActual());
  183 + next.setZdsjActualAll(sch.getZdsjActual());
  184 + }
  185 + }
  186 +
  187 + /**
  188 + * 发车漂移判定(这里出现的误判,由车辆到达中途站的时候补偿)
  189 + * @param gps
  190 + * @param prev
  191 + * @param task
  192 + * @return
  193 + */
  194 + private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){
  195 +
  196 +/* ScheduleRealInfo sch = (ScheduleRealInfo) task;
  197 + ScheduleRealInfo prevTask = dayOfSchedule.prev(sch);
  198 + if(prevTask == null || prevTask.getBcType().equals("out"))
  199 + return false;
  200 +
  201 + //计划停站时间
  202 + int stopTimePlan = (int) (sch.getDfsjT() - prevTask.getZdsjT());
  203 +
  204 + if(stopTimePlan < 1000 * 60 * 10)
  205 + return false;
  206 +
  207 + //实际停站时间
  208 + if(prevTask.getZdsjActual() != null){
  209 + int actualTime = (int) (gps.getTimestamp() - prevTask.getZdsjActualTime());
  210 +
  211 + if(actualTime < stopTimePlan * 0.8){
  212 + logger.info("漂移判定");
  213 +
  214 + return true;
  215 + }
  216 + }*/
  217 + return false;
  218 + }
  219 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 信号断线重连处理
  11 + * Created by panzhao on 2016/12/27.
  12 + */
  13 +@Component
  14 +public class OfflineSignalHandle extends SignalHandle{
  15 +
  16 + //断开3分钟,标记为重连信号
  17 + private final static int OFFLINE_TIME = 1000 * 60 * 3;
  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(isAbnormal(gps)){
  26 + return true;
  27 + }
  28 +
  29 + if(isNotEmpty(prevs)){
  30 + GpsEntity prev = prevs.getTail();
  31 + int space = (int) (gps.getTimestamp() - prev.getTimestamp());
  32 + if(space > OFFLINE_TIME)
  33 + gps.setSignalState("reconnection");
  34 +
  35 + if(space > CLEAR_TIME){
  36 + //清理缓存的信号
  37 + GeoCacheData.clear(gps.getNbbm());
  38 + }
  39 + }
  40 + return true;
  41 + }
  42 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  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.RouteReverse;
  8 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  9 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  10 +import com.bsth.data.schedule.DayOfSchedule;
  11 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +/**
  18 + * 路由反向信号处理
  19 + * Created by panzhao on 2016/12/28.
  20 + */
  21 +@Component
  22 +public class ReverseSignalHandle extends SignalHandle {
  23 +
  24 + Logger logger = LoggerFactory.getLogger(this.getClass());
  25 +
  26 + @Autowired
  27 + DayOfSchedule dayOfSchedule;
  28 +
  29 + @Override
  30 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  31 + if (!isNotEmpty(prevs))
  32 + return false;
  33 +
  34 + GpsEntity prev = prevs.getTail();
  35 +
  36 + if (isReverse(gps, prev)) {
  37 + RouteReverse reverse = reverseSearch(prevs, gps);
  38 +
  39 + if (reverse.getCount() >= 2) {
  40 + //切换到下一个班次
  41 + ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
  42 + if (sch.getBcType().equals("out") && sch.getZdsjT() != null && sch.getZdsjT() > gps.getTimestamp()) {
  43 + return false;
  44 + }
  45 + dayOfSchedule.addExecPlan(dayOfSchedule.next(sch));
  46 +
  47 + if (reverse.isClose()) {
  48 + logger.info("区间掉头,车辆:" + gps.getNbbm() + " -" + JSON.toJSONString(reverse));
  49 + }
  50 + }
  51 + }
  52 + return false;
  53 + }
  54 +
  55 + /**
  56 + * 搜索路由反向详细
  57 + *
  58 + * @param prevs
  59 + * @param gps
  60 + * @return
  61 + */
  62 + public RouteReverse reverseSearch(CircleQueue<GpsEntity> prevs, GpsEntity gps) {
  63 + RouteReverse routeReverse = new RouteReverse();
  64 + int count = 0;
  65 + String path = "";
  66 + String turned = null;
  67 +
  68 + //当前站点
  69 + StationRoute curr = GeoCacheData.getRouteCode(gps), sr;
  70 + GpsEntity prev;
  71 + Object[] array = prevs.getQueue();
  72 + for (int i = array.length - 1; i > 0; i--) {
  73 + prev = (GpsEntity) array[i];
  74 +
  75 + if(!prev.getUpDown().equals(gps.getUpDown()))
  76 + break;
  77 +
  78 + if (prev.getInstation() == 1) {
  79 + sr = GeoCacheData.getRouteCode(prev);
  80 +
  81 + if (sr.getRouteSort() > curr.getRouteSort()) {
  82 + path += (curr.getCode() + ",");
  83 + count++;
  84 + } else if (sr.getRouteSort() < curr.getRouteSort()) {
  85 + path += (curr.getCode() + ",");
  86 + //掉头点
  87 + if (turned == null)
  88 + turned = prev.getStopNo();
  89 +
  90 + //路径闭合
  91 + if (sr.getCode().equals(gps.getStopNo())) {
  92 + routeReverse.setClose(true);
  93 + path += sr.getCode();
  94 + break;
  95 + }
  96 + }
  97 +
  98 + curr = sr;
  99 + }
  100 + }
  101 +
  102 + routeReverse.setCount(count);
  103 + routeReverse.setDetail(path);
  104 + routeReverse.setTurned(turned);
  105 + return routeReverse;
  106 + }
  107 +
  108 + /**
  109 + * 是否反向
  110 + *
  111 + * @param gps
  112 + * @param prev
  113 + * @return
  114 + */
  115 + public boolean isReverse(GpsEntity gps, GpsEntity prev) {
  116 + if (gps.getInstation() == 1
  117 + &&
  118 + gps.getUpDown().equals(prev.getUpDown())
  119 + && !gps.getStopNo().equals(prev.getStopNo())) {
  120 +
  121 + StationRoute currStation = GeoCacheData.getRouteCode(gps);
  122 + StationRoute prevStation = GeoCacheData.getRouteCode(prev);
  123 +
  124 + if (currStation == null || prevStation == null)
  125 + return false;
  126 +
  127 + if (currStation.getRouteSort() < prevStation.getRouteSort())
  128 + return true;
  129 + }
  130 + return false;
  131 + }
  132 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/StationInsideHandle.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.SignalHandle;
  6 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  7 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  8 +import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 站内站外判定
  15 + * Created by panzhao on 2016/12/27.
  16 + */
  17 +@Component
  18 +public class StationInsideHandle extends SignalHandle {
  19 +
  20 +
  21 + @Override
  22 + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
  23 + //是否在场内
  24 + String parkCode = GeoUtils.gpsInCarpark(gps);
  25 + if (parkCode != null) {
  26 + gps.setInstation(2);
  27 + gps.setStopNo(parkCode);
  28 + }
  29 +
  30 + //是否在站内
  31 + List<StationRoute> srs = GeoCacheData.getStationRoute(gps.getLineId(), gps.getUpDown());
  32 + StationRoute station = GeoUtils.gpsInStation(gps, srs);
  33 + if (station != null) {
  34 + gps.setInstation(1);
  35 + gps.setStopNo(station.getCode());
  36 + gps.setStation(station);
  37 + }
  38 +
  39 + //在场,站外
  40 + if(gps.getInstation() == 0 && isNotEmpty(prevs)){
  41 + //继承上一个点的站点编码
  42 + GpsEntity prev = prevs.getTail();
  43 + gps.setStopNo(prev.getStopNo());
  44 + }
  45 +
  46 + return true;
  47 + }
  48 +}
... ...
src/main/java/com/bsth/data/gpsdata/analyse/CircleQueue.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/utils/CircleQueue.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival.utils;
2 2  
3 3 import java.util.Arrays;
4 4  
... ... @@ -19,12 +19,12 @@ public class CircleQueue&lt;T&gt; {
19 19 public Object[] elementData;
20 20  
21 21 /**
22   - * 队头(先进先出)
  22 + *
23 23 */
24 24 public int head = 0;
25 25  
26 26 /**
27   - *
  27 + *
28 28 */
29 29 public int tail = 0;
30 30  
... ... @@ -39,7 +39,7 @@ public class CircleQueue&lt;T&gt; {
39 39 }
40 40  
41 41 /**
42   - * 获取循环队列的大小(包含元素的个数)
  42 + * 获取循环队列的大小
43 43 */
44 44 public int size() {
45 45 if (isEmpty()) {
... ... @@ -87,10 +87,12 @@ public class CircleQueue&lt;T&gt; {
87 87 * @return 取 循环队列里的值(先进的index=0)
88 88 */
89 89 public Object[] getQueue() {
90   - final Object[] elementDataSort = new Object[capacity];
  90 + final Object[] elementDataSort;
91 91 final Object[] elementDataCopy = elementData.clone();
92 92 if (isEmpty()) {
  93 + elementDataSort = new Object[0];
93 94 } else if (isFull()) {
  95 + elementDataSort = new Object[capacity];
94 96 int indexMax = capacity;
95 97 int indexSort = 0;
96 98 for (int i = head; i < indexMax;) {
... ... @@ -103,6 +105,7 @@ public class CircleQueue&lt;T&gt; {
103 105 }
104 106 }
105 107 } else {
  108 + elementDataSort = new Object[tail];
106 109 for (int i = 0; i < tail; i++) {
107 110 elementDataSort[i] = elementDataCopy[i];
108 111 }
... ... @@ -110,6 +113,10 @@ public class CircleQueue&lt;T&gt; {
110 113 return elementDataSort;
111 114 }
112 115  
  116 + /**
  117 + * 取最后一个值
  118 + * @return
  119 + */
113 120 public T getTail(){
114 121 return elementData[tail] == null?null:(T)elementData[tail];
115 122 }
... ...
src/main/java/com/bsth/data/gpsdata/analyse/util/GeoUtils.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
1   -package com.bsth.data.gpsdata.analyse.util;
  1 +package com.bsth.data.gpsdata.arrival.utils;
2 2  
3 3 import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.analyse.GeoCacheData;
5   -import com.bsth.data.gpsdata.analyse.StationRoute;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
6 6 import com.vividsolutions.jts.geom.Coordinate;
7 7 import com.vividsolutions.jts.geom.GeometryFactory;
8 8 import com.vividsolutions.jts.geom.Point;
... ...
src/main/java/com/bsth/data/gpsdata/analyse/StationRouteComp.java renamed to src/main/java/com/bsth/data/gpsdata/arrival/utils/StationRouteComp.java
1   -package com.bsth.data.gpsdata.analyse;
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
2 4  
3 5 import java.util.Comparator;
4 6  
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
... ... @@ -2,13 +2,19 @@ package com.bsth.data.gpsdata.recovery;
2 2  
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.analyse.components.GpsArrival;
  5 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  6 +import com.bsth.data.gpsdata.arrival.handlers.*;
  7 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6 8 import com.bsth.util.db.DBUtils_MS;
7 9 import com.google.common.collect.ArrayListMultimap;
8 10 import org.slf4j.Logger;
9 11 import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.BeansException;
  13 +import org.springframework.context.ApplicationContext;
  14 +import org.springframework.context.ApplicationContextAware;
10 15 import org.springframework.jdbc.core.JdbcTemplate;
11 16 import org.springframework.jdbc.core.RowMapper;
  17 +import org.springframework.stereotype.Component;
12 18  
13 19 import java.sql.ResultSet;
14 20 import java.sql.SQLException;
... ... @@ -18,20 +24,25 @@ import java.util.concurrent.ExecutorService;
18 24 import java.util.concurrent.Executors;
19 25  
20 26 /**
21   - * 数据恢复
  27 + * gps数据恢复
22 28 * Created by panzhao on 2016/12/24.
23 29 */
24   -public class GpsDataRecovery {
  30 +@Component
  31 +public class GpsDataRecovery implements ApplicationContextAware{
25 32  
26 33 static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
27 34  
28 35 public static boolean run;
29 36  
30   - static ExecutorService threadPool = Executors.newFixedThreadPool(50);
  37 + static ExecutorService threadPool = Executors.newFixedThreadPool(10);
31 38  
32   - private static CountDownLatch count;
  39 + static OfflineSignalHandle offlineSignalHandle;
  40 + static CorrectSignalHandle correctSignalHandle;
  41 + static StationInsideHandle stationInsideHandle;
  42 + static InOutStationSignalHandle inOutStationSignalHandle;
  43 + static ReverseSignalHandle reverseSignalHandle;
33 44  
34   - public static void recovery() {
  45 + public void recovery() {
35 46 List<GpsEntity> list = loadData();
36 47  
37 48 //按车辆分组数据
... ... @@ -41,18 +52,20 @@ public class GpsDataRecovery {
41 52 listMap.put(gps.getNbbm(), gps);
42 53 }
43 54  
44   - count = new CountDownLatch(listMap.keySet().size());
45 55  
46 56 Set<String> keys = listMap.keySet();
  57 +
  58 + CountDownLatch count = new CountDownLatch(keys.size());
  59 + GpsComp comp = new GpsComp();
47 60 for (String nbbm : keys) {
48   - threadPool.execute(new RecoveryDataThread(listMap.get(nbbm), count));
49   - /*if(nbbm.equals("W9A-250"))
50   - new RecoveryDataThread(listMap.get(nbbm), count).run();*/
  61 + Collections.sort(listMap.get(nbbm), comp);
  62 + threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
51 63 }
  64 +
52 65 try {
53   - //等待子线程结束
54 66 count.await();
55   - logger.info("GPS 数据恢复完成....");
  67 + run = false;
  68 + logger.info("数据恢复完成....");
56 69 } catch (InterruptedException e) {
57 70 logger.error("", e);
58 71 }
... ... @@ -63,11 +76,11 @@ public class GpsDataRecovery {
63 76 *
64 77 * @return
65 78 */
66   - public static List<GpsEntity> loadData() {
  79 + public List<GpsEntity> loadData() {
67 80 Calendar calendar = Calendar.getInstance();
68 81 int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
69 82  
70   - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from BSTH_C_GPS_INFO where days_year=" + dayOfYear;
  83 + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear;
71 84 JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
72 85  
73 86 List<GpsEntity> list =
... ... @@ -102,43 +115,58 @@ public class GpsDataRecovery {
102 115 return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
103 116 }
104 117  
105   - public static class RecoveryDataThread implements Runnable {
  118 + @Override
  119 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  120 + offlineSignalHandle = applicationContext.getBean(OfflineSignalHandle.class);
  121 + correctSignalHandle = applicationContext.getBean(CorrectSignalHandle.class);
  122 + stationInsideHandle = applicationContext.getBean(StationInsideHandle.class);
  123 + inOutStationSignalHandle = applicationContext.getBean(InOutStationSignalHandle.class);
  124 + reverseSignalHandle = applicationContext.getBean(ReverseSignalHandle.class);
  125 + }
  126 +
  127 + public static class GpsComp implements Comparator<GpsEntity>{
  128 +
  129 + @Override
  130 + public int compare(GpsEntity g1, GpsEntity g2) {
  131 + return g1.getTimestamp().compareTo(g2.getTimestamp());
  132 + }
  133 + }
106 134  
  135 + public static class RecoveryThread implements Runnable{
107 136 List<GpsEntity> list;
108 137 CountDownLatch count;
109 138  
110   - public RecoveryDataThread(List<GpsEntity> list, CountDownLatch count) {
  139 + RecoveryThread(List<GpsEntity> list, CountDownLatch count){
111 140 this.list = list;
112 141 this.count = count;
113 142 }
114   -
115 143 @Override
116 144 public void run() {
117 145 try {
118   - //排序
119   - Collections.sort(list, new GpsComp());
120   - //依次跑完gps
121   - //int i = 0;
  146 + //循环gps恢复数据
  147 + CircleQueue<GpsEntity> prevs;
  148 +
122 149 for(GpsEntity gps : list){
123   - /* i++;
124   - if(i == 383){
125   - System.out.println("aaa");
126   - }*/
127   - GpsArrival.arrival(gps);
  150 + prevs = GeoCacheData.getGps(gps.getNbbm());
  151 + //掉线处理
  152 + offlineSignalHandle.handle(gps, prevs);
  153 + //状态处理
  154 + if(!correctSignalHandle.handle(gps, prevs))
  155 + continue;
  156 + //场,站内外判断
  157 + stationInsideHandle.handle(gps, prevs);
  158 + //反向处理
  159 + reverseSignalHandle.handle(gps, prevs);
  160 + //进出站动作处理
  161 + inOutStationSignalHandle.handle(gps, prevs);
  162 + GeoCacheData.putGps(gps);
128 163 }
129   - } catch (Exception e) {
  164 + }catch (Exception e){
130 165 logger.error("", e);
131   - } finally {
  166 + }
  167 + finally {
132 168 count.countDown();
133 169 }
134 170 }
135 171 }
136   -
137   - public static class GpsComp implements Comparator<GpsEntity>{
138   -
139   - @Override
140   - public int compare(GpsEntity g1, GpsEntity g2) {
141   - return (int) (g1.getTimestamp() - g2.getTimestamp());
142   - }
143   - }
144   -}
  172 +}
145 173 \ No newline at end of file
... ...
src/main/java/com/bsth/data/pilot80/PilotReport.java
1 1 package com.bsth.data.pilot80;
2 2  
3   -import java.util.ArrayList;
4   -import java.util.Collection;
5   -import java.util.List;
6   -
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 3 import com.bsth.data.BasicData;
13 4 import com.bsth.data.LineConfigData;
14 5 import com.bsth.data.gpsdata.GpsEntity;
... ... @@ -23,6 +14,14 @@ import com.bsth.repository.directive.D80Repository;
23 14 import com.bsth.service.directive.DirectiveService;
24 15 import com.bsth.websocket.handler.SendUtils;
25 16 import com.google.common.collect.ArrayListMultimap;
  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.ArrayList;
  23 +import java.util.Collection;
  24 +import java.util.List;
26 25  
27 26 /**
28 27 *
... ... @@ -180,7 +179,7 @@ public class PilotReport {
180 179 return;
181 180  
182 181 LineConfig conf = lineConfigData.get(sch.getXlBm());
183   - if(conf.getInConfig() == 1){
  182 + if(conf.getOutConfig() == 1){
184 183 //为相关班次写入进场时间
185 184 sch.setZdsjActualAll(d80.getTimestamp());
186 185  
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -37,547 +37,538 @@ import java.util.*;
37 37 import java.util.concurrent.TimeUnit;
38 38  
39 39 /**
40   - *
  40 + * @author PanZhao
41 41 * @ClassName: DayOfSchedule
42 42 * @Description: TODO(当日实际排班)
43   - * @author PanZhao
44 43 * @date 2016年8月15日 上午10:16:12
45   - *
46 44 */
47 45 @Component
48 46 public class DayOfSchedule implements CommandLineRunner {
49 47  
50   - Logger logger = LoggerFactory.getLogger(this.getClass());
51   -
52   - // 按车辆分组的班次数据
53   - private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap;
54   -
55   - // 班次主键映射
56   - private static Map<Long, ScheduleRealInfo> id2SchedulMap;
57   -
58   - // 车辆和排班起终点站对照(包括进出的停车场,区间起终点)
59   - private static TreeMultimap<String, String> nbbm2SEStationMap;
60   -
61   - //车辆 ——> 当前执行班次
62   - private static Map<String, ScheduleRealInfo> carExecutePlanMap;
63   -
64   - // 持久化缓冲区
65   - public static LinkedList<ScheduleRealInfo> pstBuffer;
66   -
67   - // 排序器
68   - private static ScheduleComparator.FCSJ schFCSJComparator;
69   -
70   - @Autowired
71   - LineConfigData lineConfigData;
72   -
73   - @Autowired
74   - ScheduleRealInfoRepository schRepository;
75   -
76   - @Autowired
77   - SchedulePlanInfoService schPlanService;
78   -
79   - @Autowired
80   - SchAttrCalculator schAttrCalculator;
81   -
82   - @Autowired
83   - SendUtils sendUtils;
84   -
85   - @Autowired
86   - GpsRealData gpsRealData;
87   -
88   - /** 线路当前使用的排班的日期 */
89   - public static Map<String, String> currSchDateMap;
90   -
91   - static {
92   - nbbmScheduleMap = ArrayListMultimap.create();
93   - id2SchedulMap = new HashMap<>();
94   - pstBuffer = new LinkedList<>();
95   - schFCSJComparator = new ScheduleComparator.FCSJ();
96   - currSchDateMap = new HashMap<>();
97   - nbbm2SEStationMap = TreeMultimap.create();
98   - carExecutePlanMap = new HashMap<>();
99   - }
100   -
101   - @Autowired
102   - ScheduleRefreshThread scheduleRefreshThread;
103   -
104   - @Autowired
105   - SchedulePstThread schedulePstThread;
106   -
107   - @Autowired
108   - FirstScheduleCheckThread firstScheduleCheckThread;
109   -
110   - @Autowired
111   - ScheduleLateThread scheduleLateThread;
112   -
113   - @Autowired
114   - SubmitToTrafficManage submitToTrafficManage;
115   -
116   - @Autowired
117   - LineConfigData lineConfigs;
118   -
119   - @Autowired
120   - BasicData.BasicDataLoader dataLoader;
121   -
122   - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd")
123   - ,fmtHHmm = DateTimeFormat.forPattern("HH:mm");
124   -
125   - @Override
126   - public void run(String... arg0) throws Exception {
127   - //加载基础数据
128   - dataLoader.loadAllData();
129   - //从数据库恢复排班
130   - //dataRecovery();
131   -
132   - //翻班线程
133   - Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
134   - //入库
135   - Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
136   - //首班出场指令补发器
137   -// Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS);
138   - //班次误点扫描
139   - Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
140   -
141   - //每天凌晨2点20提交数据到运管处
142   - long diff = (DateUtils.getTimestamp() + 1000*60*140) - System.currentTimeMillis();
143   - if(diff < 0)
144   - diff+=(1000*60*60*24);
145   -
146   - logger.info(diff/1000/60 + "分钟之后提交到运管处");
147   - //Application.mainServices.scheduleWithFixedDelay(submitToTrafficManage, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
148   - }
149   -
150   - //数据恢复
151   - private void dataRecovery() {
152   - GpsDataRecovery.run = true;
153   -
154   - Collection<LineConfig> confs = lineConfigs.getAll();
155   - String lineCode, currSchDate;
156   - for(LineConfig conf : confs){
157   - lineCode = conf.getLine().getLineCode();
158   - currSchDate = calcSchDate(lineCode);
159   - //加载班次数据
160   - reloadSch(lineCode, currSchDate, false);
161   - }
  48 + Logger logger = LoggerFactory.getLogger(this.getClass());
162 49  
163   - //恢复gps数据
164   - GpsDataRecovery.recovery();
165   - }
166   -
167   - public Map<String, String> getCurrSchDate() {
168   - return currSchDateMap;
169   - }
170   -
171   - /**
172   - *
173   - * @Title: calcSchDateB
174   - * @Description: TODO(计算线路当前应该使用的排班日期)
175   - */
176   - public String calcSchDate(String lineCode) {
177   - LineConfig conf = lineConfigData.get(lineCode);
178   - long ct = System.currentTimeMillis();
179   -
180   - String schDate = fmtyyyyMMdd.print(ct);
181   - // 小于当天起始运营时间,则取前一天的排班
182   - if (ct < conf.getCurrStartTime())
183   - schDate = DateUtils.subtractDay(schDate, 1);
184   -
185   - return schDate;
186   - }
187   -
188   - /**
189   - * @Title: reloadSch
190   - * @Title: reloadSch
191   - * @Description: TODO(重新载入排班)
192   - * @param @param
193   - * lineCode 线路编码
194   - * @param @param
195   - * schDate 班次日期 yyyy-MM-dd
196   - * @param @param
197   - * forcePlan 强制从计划调度重新抓取
198   - */
199   - public int reloadSch(String lineCode, String schDate, boolean forcePlan) {
200   - try {
201   - List<ScheduleRealInfo> list;
202   -
203   - if (forcePlan)
204   - removeRealSch(lineCode, schDate);
205   - else
206   - clearRAMData(lineCode);
207   -
208   - if (existRealSch(lineCode, schDate))
209   - list = loadRealSch(lineCode, schDate);// 从实际排班表加载
210   - else {
211   - list = loadPlanSch(lineCode, schDate);// 从计划排班表加载
212   - // 写入数据库
213   - batchSave(list);
214   - }
215   -
216   - //更新线路和班次日期对照
217   - currSchDateMap.put(lineCode, schDate);
218   - //添加到缓存
219   - putAll(list);
220   -
221   - Set<String> cars = searchAllCars(list);
222   - for(String nbbm : cars){
223   - //计算“起点站应到”时间
224   - schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm));
225   - //车辆 ——> 要执行的班次对照
226   - carExecutePlanMap.put(nbbm, schAttrCalculator.calcCurrentExecSch(nbbmScheduleMap.get(nbbm)));
227   - }
228   -
229   - //是否是出站即出场
230   - LineConfig conf = lineConfigData.get(lineCode);
231   - if(conf.getOutConfig() == 2){
232   - for(String nbbm : cars)
233   - schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm));
234   - }
235   -
236   - // 页面 翻班通知
237   - sendUtils.shiftSchedule(lineCode);
238   - } catch (Exception e) {
239   - logger.error("", e);
240   - return -1;
241   - }
  50 + // 按车辆分组的班次数据
  51 + private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap;
242 52  
243   - return 0;
244   - }
245   -
246   - /**
247   - *
248   - * @Title: searchAllCars
249   - * @Description: TODO(搜索班次集合中的车辆)
250   - */
251   - private Set<String> searchAllCars(List<ScheduleRealInfo> list) {
252   - Set<String> cars = new HashSet<>();
253   - for(ScheduleRealInfo sch : list)
254   - cars.add(sch.getClZbh());
255   -
256   - return cars;
257   - }
258   -
259   - private void putAll(List<ScheduleRealInfo> list) {
260   - for (ScheduleRealInfo sch : list)
261   - put(sch);
262   - }
263   -
264   - /**
265   - * @Title: removeRealSch
266   - * @Description: TODO(清除实际排班,包括数据库和内存数据)
267   - * @param @param
268   - * lineCode 线路编码
269   - * @param @param
270   - * schDate 班次日期 yyyy-MM-dd
271   - */
272   - public void removeRealSch(String lineCode, String schDate) throws Exception {
273   - try {
274   - // 清理数据库数据
275   - schRepository.deleteByLineCodeAndDate(lineCode + "", schDate);
276   -
277   - // 清理内存数据
278   - clearRAMData(lineCode + "");
279   - } catch (Exception e) {
280   - logger.error("removeRealSch error, " + lineCode + " -" + schDate, e);
281   - throw e;
282   - }
283   - }
284   -
285   - /**
286   - *
287   - * @Title: clearRAMData
288   - * @Description: TODO(清理内存数据)
289   - */
290   - public void clearRAMData(String lineCode) {
291   - int count = 0;
292   - List<ScheduleRealInfo> remList = new ArrayList<>();
293   - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
294   - for (ScheduleRealInfo sch : schs) {
295   - if (sch.getXlBm().equals(lineCode))
296   - remList.add(sch);
297   - }
298   -
299   - for(ScheduleRealInfo sch : remList){
300   - if(null != sch){
301   - nbbmScheduleMap.remove(sch.getClZbh(), sch);
302   - id2SchedulMap.remove(sch.getId());
303   - count ++;
304   - }
305   - }
306   -
307   - logger.info(lineCode + "排班清理 " + count);
308   - }
309   -
310   - /**
311   - * @Title: existRealSch
312   - * @Description: TODO(实际排班是否已存在)
313   - */
314   - public boolean existRealSch(String lineCode, String schDate) {
315   - int count = schRepository.countByLineCodeAndDate(lineCode, schDate);
316   - return count > 0;
317   - }
318   -
319   - /**
320   - * @Title: loadRealSch
321   - * @Description: TODO(从实际排班表加载数据)
322   - */
323   - public List<ScheduleRealInfo> loadRealSch(String lineCode, String schDate) {
324   - return schRepository.findByLineCodeAndDate(lineCode, schDate);
325   - }
326   -
327   - /**
328   - * @Title: loadPlanSch
329   - * @Description: TODO(从计划排班表加载数据)
330   - */
331   - public List<ScheduleRealInfo> loadPlanSch(String lineCode, String schDate) {
332   - logger.info("从计划排班表恢复排班,lineCode: " + lineCode + ", schDate: " + schDate);
333   - List<ScheduleRealInfo> realList = new ArrayList<>();
334   -
335   - try {
336   - Map<String, Object> data = new HashMap<>();
337   -
338   - data.put("scheduleDate_eq", fmtyyyyMMdd.parseDateTime(schDate).toDate());
339   - data.put("xlBm_eq", lineCode);
340   -
341   - // 查询计划排班
342   - List<SchedulePlanInfo> planItr = cleanSchPlanItr(schPlanService.list(data).iterator());
343   -
344   - // 转换为实际排班
345   - realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class);
346   -
347   - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
348   - String fcsj;
349   - for (ScheduleRealInfo sch : realList) {
350   - sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime()));
351   - sch.setRealExecDate(sch.getScheduleDateStr());
352   -
353   - if(StringUtils.isEmpty(sch.getFcsj()))
354   - sch.setFcsj("00:00");
355   -
356   - fcsj=sch.getFcsj().trim();
357   - //处理一下发车时间格式没有:号的问题
358   - if(fcsj.indexOf(":") == -1 && fcsj.length() >= 4){
359   - sch.setFcsj(fcsj.substring(0, 2) + ":" + fcsj.substring(2, 4));
360   - }
361   -
362   - try {
363   - sdf.parse(sch.getFcsj());
364   - } catch (ParseException e) {
365   - //发车时间仍然校验不过的,直接写成00:00
366   - sch.setFcsj("00:00");
367   - }
368   - sch.setDfsj(sch.getFcsj());
369   -
370   - // 计划终点时间
371   - if (sch.getBcsj() != null) {
372   - sch.setZdsj(fmtHHmm.print(fmtHHmm.parseMillis(sch.getFcsj()) + (sch.getBcsj() * 60 * 1000)));
373   - sch.setLate(false);
374   - }
375   - //计划里程为0,设置NULL
376   - if(sch.getJhlc() != null && sch.getJhlc() == 0)
377   - sch.setJhlc(null);
378   - }
379   - } catch (Exception e) {
380   - logger.error("", e);
381   - }
382   - return realList;
383   - }
384   -
385   - /**
386   - * @Title: batchSave
387   - * @Description: TODO(批量入库)
388   - */
389   - private void batchSave(List<ScheduleRealInfo> list) {
390   - // 查询数据库最大ID
391   - Long id = schRepository.getMaxId();
392   - if (null == id)
393   - id = 0L;
394   - id++;
395   -
396   - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
397   - for (ScheduleRealInfo item : list) {
398   - item.setSpId(item.getId());// 保留原始的计划ID
399   - item.setId(id++);// 设置ID
400   - item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate()));
401   - }
  53 + // 班次主键映射
  54 + private static Map<Long, ScheduleRealInfo> id2SchedulMap;
402 55  
403   - // 入库
404   - new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class);
405   - }
  56 + // 车辆和排班起终点站对照(包括进出的停车场,区间起终点)
  57 + private static TreeMultimap<String, String> nbbm2SEStationMap;
406 58  
407   - private List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) {
408   - List<SchedulePlanInfo> list = new ArrayList<>();
  59 + //车辆 ——> 当前执行班次
  60 + private static Map<String, ScheduleRealInfo> carExecutePlanMap;
409 61  
410   - SchedulePlanInfo sp;
411   - while (itrab.hasNext()) {
412   - sp = itrab.next();
413   - sp.setSchedulePlan(null);
414   - list.add(sp);
415   - }
416   - return list;
417   - }
418   -
419   - /**
420   - *
421   - * @Title: findByLineCode
422   - * @Description: TODO(lineCode 获取班次)
423   - */
424   - public List<ScheduleRealInfo> findByLineCode(String lineCode) {
425   - List<ScheduleRealInfo> rs = new ArrayList<>();
  62 + // 持久化缓冲区
  63 + public static LinkedList<ScheduleRealInfo> pstBuffer;
426 64  
427   - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
428   - for (ScheduleRealInfo sch : schs) {
429   - if (sch.getXlBm().equals(lineCode))
430   - rs.add(sch);
431   - }
432   - return rs;
433   - }
434   -
435   - /**
436   - *
437   - * @Title: findCarByLineCode
438   - * @Description: TODO(线路下运营的车辆)
439   - */
440   - public Set<String> findCarByLineCode(String lineCode){
441   - Set<String> rs = new HashSet<>();
442   -
443   - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
444   - for (ScheduleRealInfo sch : schs) {
445   - if (sch.getXlBm().equals(lineCode))
446   - rs.add(sch.getClZbh());
447   - }
448   -
449   - return rs;
450   - }
451   -
452   - public List<ScheduleRealInfo> findByNbbm(String nbbm) {
453   - return nbbmScheduleMap.get(nbbm);
454   - }
455   -
456   - /**
457   - *
458   - * @Title: findByLineAndUpDown
459   - * @Description: TODO(lineCode 和走向获取班次)
460   - */
461   - public List<ScheduleRealInfo> findByLineAndUpDown(String lineCode, Integer upDown) {
462   - List<ScheduleRealInfo> list = findByLineCode(lineCode), rs = new ArrayList<>();
463   -
464   - for (ScheduleRealInfo sch : list) {
465   - if (sch.getXlDir().equals(upDown + ""))
466   - rs.add(sch);
467   - }
468   - return rs;
469   - }
470   -
471   - public ScheduleRealInfo get(long id) {
472   - return id2SchedulMap.get(id);
473   - }
474   -
475   - public Set<String> getSEStationList(String nbbm) {
476   - return nbbm2SEStationMap.get(nbbm);
477   - }
478   -
479   - /**
480   - *
481   - * @Title: next
482   - * @Description: TODO(下一个班次)
483   - */
484   - public ScheduleRealInfo next(ScheduleRealInfo sch) {
485   -
486   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
487   - int outConfig = -1;
488   - LineConfig config = lineConfigData.get(sch.getXlBm());
489   - if(config != null)
490   - outConfig = config.getOutConfig();
491   -
492   - boolean flag = false;
493   - ScheduleRealInfo next = null;
494   - for(ScheduleRealInfo temp : list){
495   - if(temp.getId() == sch.getId()){
496   - flag = true;
497   - continue;
498   - }
499   - //忽略烂班
500   - if(temp.isDestroy())
501   - continue;
  65 + // 排序器
  66 + private static ScheduleComparator.FCSJ schFCSJComparator;
502 67  
503   - //出站既出场,忽略出场班次
504   - if(outConfig == 2 && temp.getBcType().equals("out"))
505   - continue;
506   -
507   - if(flag){
508   - next = temp;
509   - break;
510   - }
511   - }
512   - return next;
513   - }
514   -
515   - /**
516   - * 上一个班次
517   - * @param sch
518   - * @return
519   - */
520   - public ScheduleRealInfo prev(ScheduleRealInfo sch){
521   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
522   -
523   - //boolean flag = false;
524   - ScheduleRealInfo prev = null;
525   - int size = list.size();
526   -
527   - for(int i = 0; i < size; i ++){
528   - if(list.get(i).isDestroy())
529   - continue;
  68 + @Autowired
  69 + LineConfigData lineConfigData;
  70 +
  71 + @Autowired
  72 + ScheduleRealInfoRepository schRepository;
  73 +
  74 + @Autowired
  75 + SchedulePlanInfoService schPlanService;
  76 +
  77 + @Autowired
  78 + SchAttrCalculator schAttrCalculator;
  79 +
  80 + @Autowired
  81 + SendUtils sendUtils;
  82 +
  83 + @Autowired
  84 + GpsRealData gpsRealData;
  85 +
  86 + /**
  87 + * 线路当前使用的排班的日期
  88 + */
  89 + public static Map<String, String> currSchDateMap;
  90 +
  91 + static {
  92 + nbbmScheduleMap = ArrayListMultimap.create();
  93 + id2SchedulMap = new HashMap<>();
  94 + pstBuffer = new LinkedList<>();
  95 + schFCSJComparator = new ScheduleComparator.FCSJ();
  96 + currSchDateMap = new HashMap<>();
  97 + nbbm2SEStationMap = TreeMultimap.create();
  98 + carExecutePlanMap = new HashMap<>();
  99 + }
  100 +
  101 + @Autowired
  102 + ScheduleRefreshThread scheduleRefreshThread;
  103 +
  104 + @Autowired
  105 + SchedulePstThread schedulePstThread;
  106 +
  107 + @Autowired
  108 + FirstScheduleCheckThread firstScheduleCheckThread;
  109 +
  110 + @Autowired
  111 + ScheduleLateThread scheduleLateThread;
  112 +
  113 + @Autowired
  114 + SubmitToTrafficManage submitToTrafficManage;
  115 +
  116 + @Autowired
  117 + LineConfigData lineConfigs;
  118 +
  119 + @Autowired
  120 + BasicData.BasicDataLoader dataLoader;
  121 +
  122 + @Autowired
  123 + GpsDataRecovery gpsDataRecovery;
  124 +
  125 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"), fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  126 +
  127 + @Override
  128 + public void run(String... arg0) throws Exception {
  129 + //加载基础数据
  130 + dataLoader.loadAllData();
  131 + //从数据库恢复排班
  132 + dataRecovery();
  133 +
  134 + //翻班线程
  135 +// Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  136 + //入库
  137 +// Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS);
  138 + //首班出场指令补发器
  139 +// Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS);
  140 + //班次误点扫描
  141 + Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS);
  142 +
  143 + //每天凌晨2点20提交数据到运管处
  144 + long diff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis();
  145 + if (diff < 0)
  146 + diff += (1000 * 60 * 60 * 24);
  147 +
  148 + logger.info(diff / 1000 / 60 + "分钟之后提交到运管处");
  149 + //Application.mainServices.scheduleWithFixedDelay(submitToTrafficManage, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
  150 + }
  151 +
  152 + //数据恢复
  153 + private void dataRecovery() {
  154 + GpsDataRecovery.run = true;
  155 +
  156 + Collection<LineConfig> confs = lineConfigs.getAll();
  157 + String lineCode, currSchDate;
  158 + for (LineConfig conf : confs) {
  159 + lineCode = conf.getLine().getLineCode();
  160 + currSchDate = calcSchDate(lineCode);
  161 + //加载班次数据
  162 + reloadSch(lineCode, currSchDate, false);
  163 + }
  164 +
  165 + //恢复gps数据
  166 + gpsDataRecovery.recovery();
  167 + }
  168 +
  169 + public Map<String, String> getCurrSchDate() {
  170 + return currSchDateMap;
  171 + }
  172 +
  173 + /**
  174 + * @Title: calcSchDateB
  175 + * @Description: TODO(计算线路当前应该使用的排班日期)
  176 + */
  177 + public String calcSchDate(String lineCode) {
  178 + LineConfig conf = lineConfigData.get(lineCode);
  179 + long ct = System.currentTimeMillis();
  180 +
  181 + String schDate = fmtyyyyMMdd.print(ct);
  182 + // 小于当天起始运营时间,则取前一天的排班
  183 + if (ct < conf.getCurrStartTime())
  184 + schDate = DateUtils.subtractDay(schDate, 1);
  185 +
  186 + return schDate;
  187 + }
  188 +
  189 + /**
  190 + * @param @param lineCode 线路编码
  191 + * @param @param schDate 班次日期 yyyy-MM-dd
  192 + * @param @param forcePlan 强制从计划调度重新抓取
  193 + * @Title: reloadSch
  194 + * @Title: reloadSch
  195 + * @Description: TODO(重新载入排班)
  196 + */
  197 + public int reloadSch(String lineCode, String schDate, boolean forcePlan) {
  198 + try {
  199 + List<ScheduleRealInfo> list;
  200 +
  201 + if (forcePlan)
  202 + removeRealSch(lineCode, schDate);
  203 + else
  204 + clearRAMData(lineCode);
  205 +
  206 + if (existRealSch(lineCode, schDate))
  207 + list = loadRealSch(lineCode, schDate);// 从实际排班表加载
  208 + else {
  209 + list = loadPlanSch(lineCode, schDate);// 从计划排班表加载
  210 + // 写入数据库
  211 + batchSave(list);
  212 + }
  213 +
  214 + //更新线路和班次日期对照
  215 + currSchDateMap.put(lineCode, schDate);
  216 + //添加到缓存
  217 + putAll(list);
  218 +
  219 + Set<String> cars = searchAllCars(list);
  220 + for (String nbbm : cars) {
  221 + //计算“起点站应到”时间
  222 + schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm));
  223 + //车辆 ——> 要执行的班次对照
  224 + reCalcExecPlan(nbbm);
  225 + }
  226 +
  227 + //是否是出站即出场
  228 + LineConfig conf = lineConfigData.get(lineCode);
  229 + if (conf.getOutConfig() == 2) {
  230 + for (String nbbm : cars)
  231 + schAttrCalculator.connectOutSchedule(nbbmScheduleMap.get(nbbm));
  232 + }
  233 +
  234 + // 页面 翻班通知
  235 + sendUtils.shiftSchedule(lineCode);
  236 + } catch (Exception e) {
  237 + logger.error("", e);
  238 + return -1;
  239 + }
  240 +
  241 + return 0;
  242 + }
  243 +
  244 + /**
  245 + * @Title: searchAllCars
  246 + * @Description: TODO(搜索班次集合中的车辆)
  247 + */
  248 + private Set<String> searchAllCars(List<ScheduleRealInfo> list) {
  249 + Set<String> cars = new HashSet<>();
  250 + for (ScheduleRealInfo sch : list)
  251 + cars.add(sch.getClZbh());
  252 +
  253 + return cars;
  254 + }
  255 +
  256 + private void putAll(List<ScheduleRealInfo> list) {
  257 + for (ScheduleRealInfo sch : list)
  258 + put(sch);
  259 + }
  260 +
  261 + /**
  262 + * @param @param lineCode 线路编码
  263 + * @param @param schDate 班次日期 yyyy-MM-dd
  264 + * @Title: removeRealSch
  265 + * @Description: TODO(清除实际排班,包括数据库和内存数据)
  266 + */
  267 + public void removeRealSch(String lineCode, String schDate) throws Exception {
  268 + try {
  269 + // 清理数据库数据
  270 + schRepository.deleteByLineCodeAndDate(lineCode + "", schDate);
  271 +
  272 + // 清理内存数据
  273 + clearRAMData(lineCode + "");
  274 + } catch (Exception e) {
  275 + logger.error("removeRealSch error, " + lineCode + " -" + schDate, e);
  276 + throw e;
  277 + }
  278 + }
  279 +
  280 + /**
  281 + * @Title: clearRAMData
  282 + * @Description: TODO(清理内存数据)
  283 + */
  284 + public void clearRAMData(String lineCode) {
  285 + int count = 0;
  286 + List<ScheduleRealInfo> remList = new ArrayList<>();
  287 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
  288 + for (ScheduleRealInfo sch : schs) {
  289 + if (sch.getXlBm().equals(lineCode))
  290 + remList.add(sch);
  291 + }
  292 +
  293 + for (ScheduleRealInfo sch : remList) {
  294 + if (null != sch) {
  295 + nbbmScheduleMap.remove(sch.getClZbh(), sch);
  296 + id2SchedulMap.remove(sch.getId());
  297 + count++;
  298 + }
  299 + }
  300 +
  301 + logger.info(lineCode + "排班清理 " + count);
  302 + }
  303 +
  304 + /**
  305 + * @Title: existRealSch
  306 + * @Description: TODO(实际排班是否已存在)
  307 + */
  308 + public boolean existRealSch(String lineCode, String schDate) {
  309 + int count = schRepository.countByLineCodeAndDate(lineCode, schDate);
  310 + return count > 0;
  311 + }
  312 +
  313 + /**
  314 + * @Title: loadRealSch
  315 + * @Description: TODO(从实际排班表加载数据)
  316 + */
  317 + public List<ScheduleRealInfo> loadRealSch(String lineCode, String schDate) {
  318 + return schRepository.findByLineCodeAndDate(lineCode, schDate);
  319 + }
  320 +
  321 + /**
  322 + * @Title: loadPlanSch
  323 + * @Description: TODO(从计划排班表加载数据)
  324 + */
  325 + public List<ScheduleRealInfo> loadPlanSch(String lineCode, String schDate) {
  326 + logger.info("从计划排班表恢复排班,lineCode: " + lineCode + ", schDate: " + schDate);
  327 + List<ScheduleRealInfo> realList = new ArrayList<>();
  328 +
  329 + try {
  330 + Map<String, Object> data = new HashMap<>();
  331 +
  332 + data.put("scheduleDate_eq", fmtyyyyMMdd.parseDateTime(schDate).toDate());
  333 + data.put("xlBm_eq", lineCode);
  334 +
  335 + // 查询计划排班
  336 + List<SchedulePlanInfo> planItr = cleanSchPlanItr(schPlanService.list(data).iterator());
  337 +
  338 + // 转换为实际排班
  339 + realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class);
  340 +
  341 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  342 + String fcsj;
  343 + for (ScheduleRealInfo sch : realList) {
  344 + sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime()));
  345 + sch.setRealExecDate(sch.getScheduleDateStr());
  346 +
  347 + if (StringUtils.isEmpty(sch.getFcsj()))
  348 + sch.setFcsj("00:00");
  349 +
  350 + fcsj = sch.getFcsj().trim();
  351 + //处理一下发车时间格式没有:号的问题
  352 + if (fcsj.indexOf(":") == -1 && fcsj.length() >= 4) {
  353 + sch.setFcsj(fcsj.substring(0, 2) + ":" + fcsj.substring(2, 4));
  354 + }
  355 +
  356 + try {
  357 + sdf.parse(sch.getFcsj());
  358 + } catch (ParseException e) {
  359 + //发车时间仍然校验不过的,直接写成00:00
  360 + sch.setFcsj("00:00");
  361 + }
  362 + sch.setDfsj(sch.getFcsj());
  363 +
  364 + // 计划终点时间
  365 + if (sch.getBcsj() != null) {
  366 + sch.setZdsj(fmtHHmm.print(fmtHHmm.parseMillis(sch.getFcsj()) + (sch.getBcsj() * 60 * 1000)));
  367 + sch.setLate(false);
  368 + }
  369 + //计划里程为0,设置NULL
  370 + if (sch.getJhlc() != null && sch.getJhlc() == 0)
  371 + sch.setJhlc(null);
  372 + }
  373 + } catch (Exception e) {
  374 + logger.error("", e);
  375 + }
  376 + return realList;
  377 + }
  378 +
  379 + /**
  380 + * @Title: batchSave
  381 + * @Description: TODO(批量入库)
  382 + */
  383 + private void batchSave(List<ScheduleRealInfo> list) {
  384 + // 查询数据库最大ID
  385 + Long id = schRepository.getMaxId();
  386 + if (null == id)
  387 + id = 0L;
  388 + id++;
  389 +
  390 + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
  391 + for (ScheduleRealInfo item : list) {
  392 + item.setSpId(item.getId());// 保留原始的计划ID
  393 + item.setId(id++);// 设置ID
  394 + item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate()));
  395 + }
  396 +
  397 + // 入库
  398 + new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class);
  399 + }
  400 +
  401 + private List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) {
  402 + List<SchedulePlanInfo> list = new ArrayList<>();
  403 +
  404 + SchedulePlanInfo sp;
  405 + while (itrab.hasNext()) {
  406 + sp = itrab.next();
  407 + sp.setSchedulePlan(null);
  408 + list.add(sp);
  409 + }
  410 + return list;
  411 + }
  412 +
  413 + /**
  414 + * @Title: findByLineCode
  415 + * @Description: TODO(lineCode 获取班次)
  416 + */
  417 + public List<ScheduleRealInfo> findByLineCode(String lineCode) {
  418 + List<ScheduleRealInfo> rs = new ArrayList<>();
  419 +
  420 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
  421 + for (ScheduleRealInfo sch : schs) {
  422 + if (sch.getXlBm().equals(lineCode))
  423 + rs.add(sch);
  424 + }
  425 + return rs;
  426 + }
  427 +
  428 + /**
  429 + * @Title: findCarByLineCode
  430 + * @Description: TODO(线路下运营的车辆)
  431 + */
  432 + public Set<String> findCarByLineCode(String lineCode) {
  433 + Set<String> rs = new HashSet<>();
  434 +
  435 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
  436 + for (ScheduleRealInfo sch : schs) {
  437 + if (sch.getXlBm().equals(lineCode))
  438 + rs.add(sch.getClZbh());
  439 + }
  440 +
  441 + return rs;
  442 + }
  443 +
  444 + public List<ScheduleRealInfo> findByNbbm(String nbbm) {
  445 + return nbbmScheduleMap.get(nbbm);
  446 + }
  447 +
  448 + /**
  449 + * @Title: findByLineAndUpDown
  450 + * @Description: TODO(lineCode 和走向获取班次)
  451 + */
  452 + public List<ScheduleRealInfo> findByLineAndUpDown(String lineCode, Integer upDown) {
  453 + List<ScheduleRealInfo> list = findByLineCode(lineCode), rs = new ArrayList<>();
  454 +
  455 + for (ScheduleRealInfo sch : list) {
  456 + if (sch.getXlDir().equals(upDown + ""))
  457 + rs.add(sch);
  458 + }
  459 + return rs;
  460 + }
  461 +
  462 + public ScheduleRealInfo get(long id) {
  463 + return id2SchedulMap.get(id);
  464 + }
  465 +
  466 + public Set<String> getSEStationList(String nbbm) {
  467 + return nbbm2SEStationMap.get(nbbm);
  468 + }
  469 +
  470 + /**
  471 + * @Title: next
  472 + * @Description: TODO(下一个班次)
  473 + */
  474 + public ScheduleRealInfo next(ScheduleRealInfo sch) {
  475 +
  476 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  477 + int outConfig = -1;
  478 + LineConfig config = lineConfigData.get(sch.getXlBm());
  479 + if (config != null)
  480 + outConfig = config.getOutConfig();
  481 +
  482 + boolean flag = false;
  483 + ScheduleRealInfo next = null;
  484 + for (ScheduleRealInfo temp : list) {
  485 + if (temp.getId() == sch.getId()) {
  486 + flag = true;
  487 + continue;
  488 + }
  489 + //忽略烂班
  490 + if (temp.isDestroy())
  491 + continue;
  492 +
  493 + //出站既出场,忽略出场班次
  494 + if (outConfig == 2 && temp.getBcType().equals("out"))
  495 + continue;
  496 +
  497 + if (flag) {
  498 + next = temp;
  499 + break;
  500 + }
  501 + }
  502 + return next;
  503 + }
  504 +
  505 + /**
  506 + * 上一个班次
  507 + *
  508 + * @param sch
  509 + * @return
  510 + */
  511 + public ScheduleRealInfo prev(ScheduleRealInfo sch) {
  512 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  513 +
  514 + //boolean flag = false;
  515 + ScheduleRealInfo prev = null;
  516 + int size = list.size();
  517 +
  518 + for (int i = 0; i < size; i++) {
  519 + if (list.get(i).isDestroy())
  520 + continue;
  521 +
  522 + if (list.get(i).getId().equals(sch.getId())) {
  523 + return prev;
  524 + }
  525 + prev = list.get(i);
  526 + }
  527 + return prev;
  528 + }
  529 +
  530 + public void put(ScheduleRealInfo sch) {
  531 + schAttrCalculator
  532 + .calcRealDate(sch)
  533 + .calcAllTimeByFcsj(sch);
  534 +
  535 + String nbbm = sch.getClZbh();
  536 + nbbmScheduleMap.put(nbbm, sch);
  537 + nbbm2SEStationMap.put(nbbm, sch.getQdzCode());
  538 + nbbm2SEStationMap.put(nbbm, sch.getZdzCode());
  539 +
  540 + //主键索引
  541 + id2SchedulMap.put(sch.getId(), sch);
  542 + //跨24点的,再save一次
  543 + if (!sch.getRealExecDate().equals(sch.getScheduleDateStr()))
  544 + save(sch);
  545 + }
  546 +
  547 + public void delete(ScheduleRealInfo sch) {
  548 + //ScheduleRealInfo sch = id2SchedulMap.get(id);
  549 + if (!sch.isSflj())
  550 + return;
  551 +
  552 + nbbmScheduleMap.remove(sch.getClZbh(), sch);
  553 + id2SchedulMap.remove(sch.getId());
  554 + //return sch;
  555 + }
530 556  
531   - if(list.get(i).getId().equals(sch.getId())){
532   - return prev;
533   - }
534   - prev = list.get(i);
535   - }
536   - return prev;
537   - }
538   -
539   - public void put(ScheduleRealInfo sch) {
540   - schAttrCalculator
541   - .calcRealDate(sch)
542   - .calcAllTimeByFcsj(sch);
543   -
544   - String nbbm = sch.getClZbh();
545   - nbbmScheduleMap.put(nbbm, sch);
546   - nbbm2SEStationMap.put(nbbm, sch.getQdzCode());
547   - nbbm2SEStationMap.put(nbbm, sch.getZdzCode());
548   -
549   - //主键索引
550   - id2SchedulMap.put(sch.getId(), sch);
551   - //跨24点的,再save一次
552   - if(!sch.getRealExecDate().equals(sch.getScheduleDateStr()))
553   - save(sch);
554   - }
555   -
556   - public void delete(ScheduleRealInfo sch) {
557   - //ScheduleRealInfo sch = id2SchedulMap.get(id);
558   - if(!sch.isSflj())
559   - return;
560   -
561   - nbbmScheduleMap.remove(sch.getClZbh(), sch);
562   - id2SchedulMap.remove(sch.getId());
563   - //return sch;
564   - }
565   -
566 557 // public void calcQdzTimePlan(String nbbm){
567 558 // schAttrCalculator.calcQdzTimePlan(nbbmScheduleMap.get(nbbm));
568 559 // }
569   -
570   - public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm){
571   - return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm));
572   - }
573   -
574   - /**
575   - *
576   - * @Title: nextAll
577   - * @Description: TODO(之后的所有班次)
578   - */
  560 +
  561 + public List<ScheduleRealInfo> updateQdzTimePlan(String nbbm) {
  562 + return schAttrCalculator.updateQdzTimePlan(nbbmScheduleMap.get(nbbm));
  563 + }
  564 +
  565 + /**
  566 + *
  567 + * @Title: nextAll
  568 + * @Description: TODO(之后的所有班次)
  569 + */
579 570 /* public List<ScheduleRealInfo> nextAll(ScheduleRealInfo sch) {
580   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  571 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
581 572 // 排序
582 573 Collections.sort(list, schFCSJComparator);
583 574  
... ... @@ -592,190 +583,229 @@ public class DayOfSchedule implements CommandLineRunner {
592 583 return rs;
593 584 }*/
594 585  
595   - /**
596   - *
597   - * @Title: doneSum
598   - * @Description: TODO(已完成班次总数)
599   - */
600   - public int doneSum(String clZbh) {
601   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(clZbh);
602   - int rs = 0;
603   -
604   - for(ScheduleRealInfo sch : list){
605   - if(sch.getStatus() == 2 && !sch.isDestroy())
606   - rs ++;
607   - }
608   - return rs;
609   - }
610   -
611   - /**
612   - *
613   - * @Title: prveNotExecNum
614   - * @Description: TODO(班次之前未执行班次数量)
615   - */
616   - public int prveNotExecNum(ScheduleRealInfo sch){
617   - int n = 0;
618   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
619   - for(ScheduleRealInfo s : list){
620   - if(s.getFcsjActual() == null && !s.isDestroy())
621   - n ++;
622   -
623   - if(s.getId().equals(sch.getId()))
624   - break;
625   - }
626   - return n;
627   - }
628   -
629   - /**
630   - *
631   - * @Title: validEndTime
632   - * @Description: TODO(是否是有效的到达时间)
633   - */
634   - public boolean validEndTime(ScheduleRealInfo sch, Long ts) {
635   - if(sch.getFcsjActualTime() != null && sch.getFcsjActualTime() > ts)
636   - return false;
637   -
638   - return validTime(sch, ts);
639   - }
640   -
641   - /**
642   - *
643   - * @Title: validStartTime
644   - * @Description: TODO(是否是合适的发车时间)
645   - */
646   - public boolean validStartTime(ScheduleRealInfo sch, Long ts) {
647   - if(sch.getZdsjActualTime() != null && sch.getZdsjActualTime() < ts)
648   - return false;
649   -
650   - return validTime(sch, ts);
651   - }
652   -
653   - public boolean validTime(ScheduleRealInfo sch, Long ts){
654   - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
655   - int ci = list.indexOf(sch);
656   - ScheduleRealInfo prve, next;
657   - if(ci > 0){
658   - //之前班次实际时间不能大于该时间
659   - for(int i = ci - 1; i >= 0; i --){
660   - prve = list.get(i);
661   - if(prve.getZdsjActualTime() != null && prve.getZdsjActualTime() > ts )
662   - return false;
663   -
664   - if(prve.getFcsjActualTime() != null && prve.getFcsjActualTime() > ts)
665   - return false;
666   - }
667   - }
668   -
669   - if(ci < list.size() - 1){
670   - //之后班次实际时间不能小于该时间
671   - for(int i = ci + 1; i < list.size(); i ++){
672   - next = list.get(i);
673   - if(next.getFcsjActualTime() != null && next.getFcsjActualTime() < ts)
674   - return false;
675   -
676   - if(next.getZdsjActualTime() != null && next.getZdsjActualTime() < ts)
677   - return false;
678   - }
679   - }
680   - return true;
681   - }
682   -
683   - public void save(ScheduleRealInfo sch){
684   - //schRepository.save(sch);
685   - pstBuffer.add(sch);
686   - }
687   -
688   -
689   - /**
690   - *
691   - * @Title: nextByBcType
692   - * @Description: TODO(获取下一个指定班次类型的班次)
693   - */
694   - public ScheduleRealInfo nextByBcType(String nbbm, String bcType){
695   - List<ScheduleRealInfo> list = findByBcType(nbbm, bcType);
696   -
697   - Collections.sort(list, schFCSJComparator);
698   - ScheduleRealInfo sch = null;
699   - for(ScheduleRealInfo temp : list){
700   - if(temp.getFcsjActual() == null)
701   - sch = temp;
702   - }
703   -
704   - return sch;
705   - }
706   -
707   - public List<ScheduleRealInfo> findByBcType(String nbbm, String bcType){
708   - List<ScheduleRealInfo> all = nbbmScheduleMap.get(nbbm)
709   - ,outList = new ArrayList<>();
710   -
711   - for(ScheduleRealInfo sch : all){
712   - if(sch.getBcType().equals(bcType))
713   - outList.add(sch);
714   - }
715   - return outList;
716   - }
717   -
718   - public Set<String> allCar(){
719   - return nbbmScheduleMap.keySet();
720   - }
721   -
722   - public Collection<ScheduleRealInfo> findAll(){
723   - return nbbmScheduleMap.values();
724   - }
725   -
726   - public void addExecPlan(ScheduleRealInfo sch){
727   - carExecutePlanMap.put(sch.getClZbh(), sch);
728   - }
729   -
730   - public void removeExecPlan(String clzbh){
731   - carExecutePlanMap.remove(clzbh);
732   - }
733   -
734   - public Map<String, ScheduleRealInfo> execPlanMap(){
735   - return carExecutePlanMap;
736   - }
737   -
738   - /**
739   - * 车辆当前执行的班次
740   - * @param nbbm
741   - * @return
742   - */
743   - public static ScheduleRealInfo executeCurr(String nbbm){
744   - return carExecutePlanMap.get(nbbm);
745   - }
746   -
747   - /**
748   - * @Title: changeCar
749   - * @Description: TODO(班次换车) 返回有更新的班次
750   - * @param @param sch
751   - * @param @param newClZbh 新的车辆自编号
752   - */
753   - public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch , String newClZbh){
754   - List<ScheduleRealInfo> ups = new ArrayList<>();
755   - String oldClzbh = sch.getClZbh();
756   - if(oldClzbh.equals(newClZbh))
757   - return ups;
758   -
759   -
760   - //变更相关映射信息
761   - nbbmScheduleMap.remove(sch.getClZbh(), sch);
762   -
763   - sch.setClZbh(newClZbh);
764   - nbbmScheduleMap.put(newClZbh, sch);
765   - nbbm2SEStationMap.put(newClZbh, sch.getQdzCode());
766   - nbbm2SEStationMap.put(newClZbh, sch.getZdzCode());
767   -
768   - //重新计算班次应到时间
769   - ups.addAll(updateQdzTimePlan(oldClzbh));
770   - ups.addAll(updateQdzTimePlan(newClZbh));
771   - return ups;
772   - }
773   -
774   - /**
775   - *
776   - * @Title: linkToSchPlan
777   - * @Description: TODO(车辆关联到班次)
778   - */
  586 + /**
  587 + * @Title: doneSum
  588 + * @Description: TODO(已完成班次总数)
  589 + */
  590 + public int doneSum(String clZbh) {
  591 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(clZbh);
  592 + int rs = 0;
  593 +
  594 + for (ScheduleRealInfo sch : list) {
  595 + if (sch.getStatus() == 2 && !sch.isDestroy())
  596 + rs++;
  597 + }
  598 + return rs;
  599 + }
  600 +
  601 + /**
  602 + * @Title: prveNotExecNum
  603 + * @Description: TODO(班次之前未执行班次数量)
  604 + */
  605 + public int prveNotExecNum(ScheduleRealInfo sch) {
  606 + int n = 0;
  607 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  608 + for (ScheduleRealInfo s : list) {
  609 + if (s.getFcsjActual() == null && !s.isDestroy())
  610 + n++;
  611 +
  612 + if (s.getId().equals(sch.getId()))
  613 + break;
  614 + }
  615 + return n;
  616 + }
  617 +
  618 + /**
  619 + * @Title: validEndTime
  620 + * @Description: TODO(是否是有效的到达时间)
  621 + */
  622 + public boolean validEndTime(ScheduleRealInfo sch, Long ts) {
  623 + if (sch.getFcsjActualTime() != null && sch.getFcsjActualTime() > ts)
  624 + return false;
  625 +
  626 + return validTime(sch, ts);
  627 + }
  628 +
  629 + /**
  630 + * @Title: validStartTime
  631 + * @Description: TODO(是否是合适的发车时间)
  632 + */
  633 + public boolean validStartTime(ScheduleRealInfo sch, Long ts) {
  634 + if (sch.getZdsjActualTime() != null && sch.getZdsjActualTime() < ts)
  635 + return false;
  636 +
  637 + return validTime(sch, ts);
  638 + }
  639 +
  640 + public boolean validTime(ScheduleRealInfo sch, Long ts) {
  641 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());
  642 + int ci = list.indexOf(sch);
  643 + ScheduleRealInfo prve, next;
  644 + if (ci > 0) {
  645 + //之前班次实际时间不能大于该时间
  646 + for (int i = ci - 1; i >= 0; i--) {
  647 + prve = list.get(i);
  648 + if (prve.getZdsjActualTime() != null && prve.getZdsjActualTime() > ts)
  649 + return false;
  650 +
  651 + if (prve.getFcsjActualTime() != null && prve.getFcsjActualTime() > ts)
  652 + return false;
  653 + }
  654 + }
  655 +
  656 + if (ci < list.size() - 1) {
  657 + //之后班次实际时间不能小于该时间
  658 + for (int i = ci + 1; i < list.size(); i++) {
  659 + next = list.get(i);
  660 + if (next.getFcsjActualTime() != null && next.getFcsjActualTime() < ts)
  661 + return false;
  662 +
  663 + if (next.getZdsjActualTime() != null && next.getZdsjActualTime() < ts)
  664 + return false;
  665 + }
  666 + }
  667 + return true;
  668 + }
  669 +
  670 + public void save(ScheduleRealInfo sch) {
  671 + //schRepository.save(sch);
  672 + pstBuffer.add(sch);
  673 + }
  674 +
  675 +
  676 + /**
  677 + * @Title: nextByBcType
  678 + * @Description: TODO(获取下一个指定班次类型的班次)
  679 + */
  680 + public ScheduleRealInfo nextByBcType(String nbbm, String bcType) {
  681 + List<ScheduleRealInfo> list = findByBcType(nbbm, bcType);
  682 +
  683 + Collections.sort(list, schFCSJComparator);
  684 + ScheduleRealInfo sch = null;
  685 + for (ScheduleRealInfo temp : list) {
  686 + if (temp.getFcsjActual() == null)
  687 + sch = temp;
  688 + }
  689 +
  690 + return sch;
  691 + }
  692 +
  693 + public List<ScheduleRealInfo> findByBcType(String nbbm, String bcType) {
  694 + List<ScheduleRealInfo> all = nbbmScheduleMap.get(nbbm), outList = new ArrayList<>();
  695 +
  696 + for (ScheduleRealInfo sch : all) {
  697 + if (sch.getBcType().equals(bcType))
  698 + outList.add(sch);
  699 + }
  700 + return outList;
  701 + }
  702 +
  703 + public Set<String> allCar() {
  704 + return nbbmScheduleMap.keySet();
  705 + }
  706 +
  707 + public Collection<ScheduleRealInfo> findAll() {
  708 + return nbbmScheduleMap.values();
  709 + }
  710 +
  711 + public void addExecPlan(ScheduleRealInfo sch) {
  712 + if(sch != null)
  713 + carExecutePlanMap.put(sch.getClZbh(), sch);
  714 + }
  715 +
  716 + public void removeExecPlan(String clzbh) {
  717 + carExecutePlanMap.remove(clzbh);
  718 + }
  719 +
  720 + public Map<String, ScheduleRealInfo> execPlanMap() {
  721 + return carExecutePlanMap;
  722 + }
  723 +
  724 + /**
  725 + * 车辆当前执行的班次
  726 + *
  727 + * @param nbbm
  728 + * @return
  729 + */
  730 + public ScheduleRealInfo executeCurr(String nbbm) {
  731 + return carExecutePlanMap.get(nbbm);
  732 + }
  733 +
  734 + /**
  735 + * @param @param sch
  736 + * @param @param newClZbh 新的车辆自编号
  737 + * @Title: changeCar
  738 + * @Description: TODO(班次换车) 返回有更新的班次
  739 + */
  740 + public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) {
  741 + List<ScheduleRealInfo> ups = new ArrayList<>();
  742 + String oldClzbh = sch.getClZbh();
  743 + if (oldClzbh.equals(newClZbh))
  744 + return ups;
  745 +
  746 +
  747 + //变更相关映射信息
  748 + nbbmScheduleMap.remove(sch.getClZbh(), sch);
  749 +
  750 + sch.setClZbh(newClZbh);
  751 + nbbmScheduleMap.put(newClZbh, sch);
  752 + nbbm2SEStationMap.put(newClZbh, sch.getQdzCode());
  753 + nbbm2SEStationMap.put(newClZbh, sch.getZdzCode());
  754 +
  755 + //重新计算班次应到时间
  756 + ups.addAll(updateQdzTimePlan(oldClzbh));
  757 + ups.addAll(updateQdzTimePlan(newClZbh));
  758 +
  759 + //重新计算车辆当前执行班次
  760 + reCalcExecPlan(newClZbh);
  761 + reCalcExecPlan(sch.getClZbh());
  762 + return ups;
  763 + }
  764 +
  765 + public void reCalcExecPlan(String nbbm){
  766 + carExecutePlanMap.put(nbbm, schAttrCalculator.calcCurrentExecSch(nbbmScheduleMap.get(nbbm)));
  767 + }
  768 +
  769 + /**
  770 + * 是否在执行首班出场
  771 + * @param nbbm
  772 + * @return
  773 + */
  774 + public boolean isExecFirstOut(String nbbm, long time){
  775 + try {
  776 + List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
  777 + ScheduleRealInfo second = list.get(2),
  778 + first = executeCurr(nbbm);
  779 +
  780 + if(first.getBcType().equals("out")
  781 + && first.getDfsjT() < second.getDfsjT()
  782 + && doneSum(nbbm) == 0 && second.getDfsjT() > time)
  783 + return true;
  784 + } catch (Exception e) {
  785 + logger.error("", e);
  786 + }
  787 +
  788 + return false;
  789 + }
  790 +
  791 + /**
  792 + * 获取班次的计划停站时间
  793 + * @param sch
  794 + * @return
  795 +
  796 + public int stopTimePlan(Object task) {
  797 +
  798 + ScheduleRealInfo sch = prev((ScheduleRealInfo) task);
  799 +
  800 + sch.getzdsj
  801 + return -1;
  802 + }*/
  803 +
  804 + /**
  805 + *
  806 + * @Title: linkToSchPlan
  807 + * @Description: TODO(车辆关联到班次)
  808 + */
779 809 /* public void linkToSchPlan(String nbbm) {
780 810 //当前GPS状态
781 811 GpsEntity gps = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm));
... ...
src/main/java/com/bsth/entity/Cars.java
... ... @@ -23,7 +23,7 @@ import java.util.Date;
23 23  
24 24 @Entity
25 25 @Table(name = "bsth_c_cars")
26   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  26 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
27 27 public class Cars extends BEntity implements Serializable {
28 28  
29 29 /** 主键Id */
... ...
src/main/java/com/bsth/entity/Line.java
... ... @@ -24,7 +24,7 @@ import java.util.Date;
24 24  
25 25 @Entity
26 26 @Table(name = "bsth_c_line")
27   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  27 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
28 28 public class Line implements Serializable {
29 29  
30 30 @Id
... ...
src/main/java/com/bsth/entity/Personnel.java
... ... @@ -21,7 +21,7 @@ import javax.persistence.*;
21 21  
22 22 @Entity
23 23 @Table(name = "bsth_c_personnel")
24   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  24 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
25 25 public class Personnel extends BEntity {
26 26  
27 27 /** 主键Id */
... ...
src/main/java/com/bsth/entity/realcontrol/LineConfig.java
1 1 package com.bsth.entity.realcontrol;
2 2  
  3 +import com.bsth.entity.Line;
  4 +
  5 +import javax.persistence.*;
3 6 import java.text.ParseException;
4 7 import java.text.SimpleDateFormat;
5 8 import java.util.Date;
6 9 import java.util.HashSet;
7 10 import java.util.Set;
8 11  
9   -import javax.persistence.CascadeType;
10   -import javax.persistence.Entity;
11   -import javax.persistence.GeneratedValue;
12   -import javax.persistence.Id;
13   -import javax.persistence.NamedAttributeNode;
14   -import javax.persistence.NamedEntityGraph;
15   -import javax.persistence.NamedEntityGraphs;
16   -import javax.persistence.OneToMany;
17   -import javax.persistence.OneToOne;
18   -import javax.persistence.Table;
19   -import javax.persistence.Transient;
20   -
21   -import com.bsth.entity.Line;
22   -import com.bsth.util.DateUtils;
23   -
24 12 /**
25 13 *
26 14 * @ClassName: LineConfig
... ... @@ -59,9 +47,6 @@ public class LineConfig {
59 47 /** 出场时间设置 0:真实出场(设备离开缓冲区时间) 1:请求出场时间 2:出站即出场 */
60 48 private int outConfig;
61 49  
62   - /** 进场时间设置 0:真实进场(设备进入缓冲区时间) 1:请求进场时间 2:出站即出场*/
63   - private int inConfig;
64   -
65 50 /** 短语模板 , 号分隔多个 */
66 51 private String phraseTemps;
67 52  
... ... @@ -111,14 +96,6 @@ public class LineConfig {
111 96 this.outConfig = outConfig;
112 97 }
113 98  
114   - public int getInConfig() {
115   - return inConfig;
116   - }
117   -
118   - public void setInConfig(int inConfig) {
119   - this.inConfig = inConfig;
120   - }
121   -
122 99 public String getPhraseTemps() {
123 100 return phraseTemps;
124 101 }
... ...
src/main/java/com/bsth/entity/schedule/CarConfigInfo.java
... ... @@ -19,7 +19,7 @@ import java.util.Date;
19 19 @NamedAttributeNode("cl")
20 20 })
21 21 })
22   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  22 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
23 23 public class CarConfigInfo extends BEntity implements Serializable {
24 24  
25 25 /** 主健Id */
... ...
src/main/java/com/bsth/entity/schedule/EmployeeConfigInfo.java
... ... @@ -22,7 +22,7 @@ import java.io.Serializable;
22 22 @NamedAttributeNode("xl")
23 23 })
24 24 })
25   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  25 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
26 26 public class EmployeeConfigInfo extends BEntity implements Serializable {
27 27  
28 28 /** 主键Id */
... ...
src/main/java/com/bsth/entity/schedule/GuideboardInfo.java
... ... @@ -15,7 +15,7 @@ import javax.persistence.*;
15 15 @NamedAttributeNode("xl")
16 16 })
17 17 })
18   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  18 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
19 19 public class GuideboardInfo extends BEntity {
20 20  
21 21 /** 主键Id */
... ...
src/main/java/com/bsth/entity/sys/SysUser.java
... ... @@ -9,7 +9,7 @@ import java.util.Set;
9 9  
10 10 @Entity
11 11 @Table(name = "bsth_c_sys_user")
12   -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  12 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"})
13 13 public class SysUser {
14 14  
15 15 @Id
... ...
src/main/java/com/bsth/service/BusIntervalService.java
... ... @@ -8,6 +8,8 @@ public interface BusIntervalService {
8 8  
9 9 List<Map<String, Object>> getDir(Map<String, Object> map);
10 10  
  11 + List<Map<String, Object>> getLp(Map<String, Object> map);
  12 +
11 13 List<Map<String, Object>> interval(Map<String, Object> map);
12 14  
13 15 Map<String, Object> timeAndSpeed(Map<String, Object> map);
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -290,6 +290,7 @@ public class FormsServiceImpl implements FormsService {
290 290  
291 291 List<Changetochange> list = jdbcTemplate.query(sql, new RowMapper<Changetochange>() {
292 292  
  293 +
293 294 @Override
294 295 public Changetochange mapRow(ResultSet arg0, int arg1) throws SQLException {
295 296 Changetochange chan = new Changetochange();
... ... @@ -314,6 +315,7 @@ public class FormsServiceImpl implements FormsService {
314 315 return list;
315 316 }
316 317  
  318 +
317 319 // 路单数据
318 320 @Override
319 321 public List<Singledata> singledata(Map<String, Object> map) {
... ...