Commit d0d6cc3ea1473aae5712d9d8e5e214b931300514

Authored by 娄高锋
2 parents be92a6fe 18f3a942

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

Showing 27 changed files with 2084 additions and 1669 deletions
src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -64,6 +64,11 @@ public class ReportController {
64 64 return service.tbodyTime3(line, ttinfo);
65 65 }
66 66  
  67 + @RequestMapping(value = "/tbodyTime4", method = RequestMethod.GET)
  68 + public List<Map<String, Object>> tbodyTime4(@RequestParam String line,@RequestParam String ttinfo) {
  69 + return service.tbodyTime4(line, ttinfo);
  70 + }
  71 +
67 72 @RequestMapping(value = "/tbodyTime5", method = RequestMethod.GET)
68 73 public List<Map<String, Object>> tbodyTime5(@RequestParam String line,@RequestParam String ttinfo) {
69 74 return service.tbodyTime5(line, ttinfo);
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
1   -package com.bsth.data.gpsdata.arrival;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
5   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6   -import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
7   -import com.google.common.collect.ArrayListMultimap;
8   -import com.vividsolutions.jts.geom.Coordinate;
9   -import com.vividsolutions.jts.geom.GeometryFactory;
10   -import com.vividsolutions.jts.geom.LineString;
11   -import com.vividsolutions.jts.geom.Polygon;
12   -import org.apache.commons.lang3.StringUtils;
13   -import org.slf4j.Logger;
14   -import org.slf4j.LoggerFactory;
15   -import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.jdbc.core.JdbcTemplate;
17   -import org.springframework.jdbc.core.RowMapper;
18   -import org.springframework.stereotype.Component;
19   -
20   -import java.sql.ResultSet;
21   -import java.sql.SQLException;
22   -import java.util.*;
23   -
24   -/**
25   - * Created by panzhao on 2016/12/23.
26   - */
27   -@Component
28   -public class GeoCacheData {
29   -
30   - static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
31   -
32   - //每辆车缓存最后500条gps
33   - private static final int CACHE_SIZE = 500;
34   - private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
35   -
36   - //线路路段走向
37   - private static ArrayListMultimap<String, LineString> sectionCacheMap;
38   -
39   - //线路站点路由
40   - private static ArrayListMultimap<String, StationRoute> stationCacheMap;
41   -
42   - //线路_上下行_站点编码 ——> 站点
43   - private static Map<String, StationRoute> routeCodeMap;
44   -
45   - //停车场
46   - public static Map<String, Polygon> tccMap;
47   -
48   - @Autowired
49   - JdbcTemplate jdbcTemplate;
50   -
51   - public static CircleQueue<GpsEntity> getGps(String nbbm) {
52   - return gpsCacheMap.get(nbbm);
53   - }
54   -
55   - public static void putGps(GpsEntity gps) {
56   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
57   - if (queue == null) {
58   - /*//第一个点从站内开始
59   - if (gps.getInstation() == 0)
60   - return;*/
61   -
62   - queue = new CircleQueue<>(CACHE_SIZE);
63   - gpsCacheMap.put(gps.getNbbm(), queue);
64   - }
65   - queue.add(gps);
66   - }
67   -
68   - public static void clear(String nbbm) {
69   - try {
70   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
71   - if (queue != null)
72   - queue.clear();
73   - } catch (Exception e) {
74   - logger.error("", e);
75   - }
76   - }
77   -
78   - public static StationRoute getRouteCode(GpsEntity gps){
79   - return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
80   - }
81   -
82   - public static List<StationRoute> getStationRoute(String lineCode, int directions) {
83   - return stationCacheMap.get(lineCode + "_" + directions);
84   - }
85   -
86   - public static StationRoute getStation(String lineCode, int directions, String code) {
87   - List<StationRoute> list = getStationRoute(lineCode, directions);
88   -
89   - for (StationRoute sr : list) {
90   - if (sr.getCode().equals(code)) {
91   - return sr;
92   - }
93   - }
94   - return null;
95   - }
96   -
97   - public static Polygon getTccPolygon(String code) {
98   - return tccMap.get(code);
99   - }
100   -
101   - public void loadData() {
102   - final GeometryFactory geometryFactory = new GeometryFactory();
103   - //加载站点路由
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";
105   - List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
106   - @Override
107   - public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
108   - StationRoute sRoute = new StationRoute();
109   - sRoute.setCode(rs.getString("STATION_CODE"));
110   - sRoute.setLineCode(rs.getString("LINE_CODE"));
111   - sRoute.setDirections(rs.getInt("DIRECTIONS"));
112   - sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX"))));
113   - sRoute.setRadius(rs.getFloat("RADIUS"));
114   - sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
115   - sRoute.setMark(rs.getString("STATION_MARK"));
116   - sRoute.setName(rs.getString("STATION_NAME"));
117   -
118   - String shapesType = rs.getString("SHAPES_TYPE");
119   - //多边形电子围栏
120   - if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
121   - sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
122   - }
123   - return sRoute;
124   - }
125   - });
126   - //按线路和走向分组
127   - if (routeList.size() > 0) {
128   - ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
129   - Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
130   - for (StationRoute sr : routeList) {
131   - tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
132   - //站点编码 ——> 和路由顺序对照
133   - codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
134   - }
135   -
136   - StationRouteComp srCom = new StationRouteComp();
137   - //连接路由
138   - Set<String> set = tempMap.keySet();
139   - for (String key : set) {
140   - Collections.sort(tempMap.get(key), srCom);
141   - connectStationRoute(tempMap.get(key));
142   - }
143   -
144   - stationCacheMap = tempMap;
145   - routeCodeMap = codeMap;
146   - }
147   -
148   - //加载停车场数据
149   - sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
150   - List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
151   - Map<String, Polygon> tccTempMap = new HashMap<>();
152   -
153   - Polygon polygon;
154   - for (Map<String, Object> tMap : tccList) {
155   -
156   - try {
157   - polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString()));
158   - tccTempMap.put(tMap.get("PARK_CODE").toString()
159   - , polygon);
160   - } catch (Exception e) {
161   - logger.error("停车场:" + tMap.get("PARK_CODE"), e);
162   - }
163   - }
164   -
165   - if (tccTempMap.size() > 0)
166   - tccMap = tccTempMap;
167   - }
168   -
169   - private void connectStationRoute(List<StationRoute> list) {
170   - int size = list.size();
171   - StationRoute sr = null;
172   - for (int i = 0; i < size; i++) {
173   - sr = list.get(i);
174   - //上一个
175   - if (i > 0)
176   - sr.setPrve(list.get(i - 1));
177   - //下一个
178   - if (i < size - 1)
179   - sr.setNext(list.get(i + 1));
180   - }
181   - }
182   -
183   - public Coordinate[] parsePolygon(String polygonStr) {
184   - String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
185   -
186   - Coordinate[] cds = new Coordinate[coords.length];
187   - int len = coords.length;
188   - for (int i = 0; i < len; i++) {
189   - temps = coords[i].split(" ");
190   - cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0]));
191   - }
192   - return cds;
193   - }
  1 +package com.bsth.data.gpsdata.arrival;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  5 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  6 +import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import com.vividsolutions.jts.geom.Coordinate;
  9 +import com.vividsolutions.jts.geom.GeometryFactory;
  10 +import com.vividsolutions.jts.geom.LineString;
  11 +import com.vividsolutions.jts.geom.Polygon;
  12 +import org.apache.commons.lang3.StringUtils;
  13 +import org.slf4j.Logger;
  14 +import org.slf4j.LoggerFactory;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
  17 +import org.springframework.jdbc.core.RowMapper;
  18 +import org.springframework.stereotype.Component;
  19 +
  20 +import java.sql.ResultSet;
  21 +import java.sql.SQLException;
  22 +import java.util.*;
  23 +
  24 +/**
  25 + * Created by panzhao on 2016/12/23.
  26 + */
  27 +@Component
  28 +public class GeoCacheData {
  29 +
  30 + static Logger logger = LoggerFactory.getLogger(GeoCacheData.class);
  31 +
  32 + //每辆车缓存最后500条gps
  33 + private static final int CACHE_SIZE = 500;
  34 + private static Map<String, CircleQueue<GpsEntity>> gpsCacheMap = new HashMap<>();
  35 +
  36 + //线路路段走向
  37 + private static ArrayListMultimap<String, LineString> sectionCacheMap;
  38 +
  39 + //线路站点路由
  40 + private static ArrayListMultimap<String, StationRoute> stationCacheMap;
  41 +
  42 + //线路_上下行_站点编码 ——> 站点
  43 + private static Map<String, StationRoute> routeCodeMap;
  44 +
  45 + //停车场
  46 + public static Map<String, Polygon> tccMap;
  47 +
  48 + @Autowired
  49 + JdbcTemplate jdbcTemplate;
  50 +
  51 + public static CircleQueue<GpsEntity> getGps(String nbbm) {
  52 + return gpsCacheMap.get(nbbm);
  53 + }
  54 +
  55 + public static void putGps(GpsEntity gps) {
  56 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getNbbm());
  57 + if (queue == null) {
  58 + /*//第一个点从站内开始
  59 + if (gps.getInstation() == 0)
  60 + return;*/
  61 +
  62 + queue = new CircleQueue<>(CACHE_SIZE);
  63 + gpsCacheMap.put(gps.getNbbm(), queue);
  64 + }
  65 + queue.add(gps);
  66 + }
  67 +
  68 + public static void clear(String nbbm) {
  69 + try {
  70 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(nbbm);
  71 + if (queue != null)
  72 + queue.clear();
  73 + } catch (Exception e) {
  74 + logger.error("", e);
  75 + }
  76 + }
  77 +
  78 + public static StationRoute getRouteCode(GpsEntity gps){
  79 + return routeCodeMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo());
  80 + }
  81 +
  82 + public static List<StationRoute> getStationRoute(String lineCode, int directions) {
  83 + return stationCacheMap.get(lineCode + "_" + directions);
  84 + }
  85 +
  86 + public static StationRoute getStation(String lineCode, int directions, String code) {
  87 + List<StationRoute> list = getStationRoute(lineCode, directions);
  88 +
  89 + for (StationRoute sr : list) {
  90 + if (sr.getCode().equals(code)) {
  91 + return sr;
  92 + }
  93 + }
  94 + return null;
  95 + }
  96 +
  97 + public static Polygon getTccPolygon(String code) {
  98 + return tccMap.get(code);
  99 + }
  100 +
  101 + public void loadData() {
  102 + final GeometryFactory geometryFactory = new GeometryFactory();
  103 + //加载站点路由
  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";
  105 + List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() {
  106 + @Override
  107 + public StationRoute mapRow(ResultSet rs, int rowNum) throws SQLException {
  108 + StationRoute sRoute = new StationRoute();
  109 + sRoute.setCode(rs.getString("STATION_CODE"));
  110 + sRoute.setLineCode(rs.getString("LINE_CODE"));
  111 + sRoute.setDirections(rs.getInt("DIRECTIONS"));
  112 + sRoute.setPoint(geometryFactory.createPoint(new Coordinate(rs.getFloat("G_LATY"), rs.getFloat("G_LONX"))));
  113 + sRoute.setRadius(rs.getFloat("RADIUS"));
  114 + sRoute.setRouteSort(rs.getInt("STATION_ROUTE_CODE"));
  115 + sRoute.setMark(rs.getString("STATION_MARK"));
  116 + sRoute.setName(rs.getString("STATION_NAME"));
  117 +
  118 + String shapesType = rs.getString("SHAPES_TYPE");
  119 + //多边形电子围栏
  120 + if (StringUtils.isNotEmpty(shapesType) && shapesType.equals("d")) {
  121 + sRoute.setPolygon(geometryFactory.createPolygon(parsePolygon(rs.getString("G_POLYGON_GRID"))));
  122 + }
  123 + return sRoute;
  124 + }
  125 + });
  126 + //按线路和走向分组
  127 + if (routeList.size() > 0) {
  128 + ArrayListMultimap<String, StationRoute> tempMap = ArrayListMultimap.create();
  129 + Map<String, StationRoute> codeMap = new HashMap<>(routeList.size());
  130 + for (StationRoute sr : routeList) {
  131 + tempMap.put(sr.getLineCode() + "_" + sr.getDirections(), sr);
  132 + //站点编码 ——> 和路由顺序对照
  133 + codeMap.put(sr.getLineCode() + "_" + sr.getDirections() + "_" + sr.getCode(), sr);
  134 + }
  135 +
  136 + StationRouteComp srCom = new StationRouteComp();
  137 + //连接路由
  138 + Set<String> set = tempMap.keySet();
  139 + for (String key : set) {
  140 + Collections.sort(tempMap.get(key), srCom);
  141 + connectStationRoute(tempMap.get(key));
  142 + }
  143 +
  144 + stationCacheMap = tempMap;
  145 + routeCodeMap = codeMap;
  146 + }
  147 +
  148 + //加载停车场数据
  149 + sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null";
  150 + List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql);
  151 + Map<String, Polygon> tccTempMap = new HashMap<>();
  152 +
  153 + Polygon polygon;
  154 + for (Map<String, Object> tMap : tccList) {
  155 +
  156 + try {
  157 + polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString()));
  158 + tccTempMap.put(tMap.get("PARK_CODE").toString()
  159 + , polygon);
  160 + } catch (Exception e) {
  161 + logger.error("停车场:" + tMap.get("PARK_CODE"), e);
  162 + }
  163 + }
  164 +
  165 + if (tccTempMap.size() > 0)
  166 + tccMap = tccTempMap;
  167 + }
  168 +
  169 + private void connectStationRoute(List<StationRoute> list) {
  170 + int size = list.size();
  171 + StationRoute sr = null;
  172 + for (int i = 0; i < size; i++) {
  173 + sr = list.get(i);
  174 + //上一个
  175 + if (i > 0)
  176 + sr.setPrve(list.get(i - 1));
  177 + //下一个
  178 + if (i < size - 1)
  179 + sr.setNext(list.get(i + 1));
  180 + }
  181 + }
  182 +
  183 + public Coordinate[] parsePolygon(String polygonStr) {
  184 + String[] coords = polygonStr.substring(9, polygonStr.length() - 2).split(","), temps;
  185 +
  186 + Coordinate[] cds = new Coordinate[coords.length];
  187 + int len = coords.length;
  188 + for (int i = 0; i < len; i++) {
  189 + temps = coords[i].split(" ");
  190 + cds[i] = new Coordinate(Float.parseFloat(temps[1]), Float.parseFloat(temps[0]));
  191 + }
  192 + return cds;
  193 + }
194 194 }
195 195 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java
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   -}
  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
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   -}
  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
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   -}
  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/arrival/entity/StationRoute.java
1   -package com.bsth.data.gpsdata.arrival.entity;
2   -
3   -import com.vividsolutions.jts.geom.Point;
4   -import com.vividsolutions.jts.geom.Polygon;
5   -
6   -/**
7   - * Created by panzhao on 2016/12/23.
8   - */
9   -public class StationRoute {
10   -
11   - /**
12   - * 线路编码
13   - */
14   - private String lineCode;
15   -
16   - /**
17   - * 上下行
18   - */
19   - private int directions;
20   -
21   - /**
22   - * 站点编码
23   - */
24   - private String code;
25   -
26   - /**
27   - * 路由顺序
28   - */
29   - private int routeSort;
30   -
31   - /**
32   - * 站点位置
33   - */
34   - private Point point;
35   -
36   - /**
37   - * 圆形半径
38   - */
39   - private Float radius;
40   -
41   - /**
42   - * 多边形电子围栏
43   - */
44   - private Polygon polygon;
45   -
46   - /**
47   - * 站点标记
48   - */
49   - private String mark;
50   -
51   - /**
52   - * 下一站
53   - */
54   - private StationRoute next;
55   -
56   - /**
57   - * 上一站
58   - */
59   - private StationRoute prve;
60   -
61   - private String name;
62   -
63   - public String getCode() {
64   - return code;
65   - }
66   -
67   - public void setCode(String code) {
68   - this.code = code;
69   - }
70   -
71   - public int getRouteSort() {
72   - return routeSort;
73   - }
74   -
75   - public void setRouteSort(int routeSort) {
76   - this.routeSort = routeSort;
77   - }
78   -
79   - public Point getPoint() {
80   - return point;
81   - }
82   -
83   - public void setPoint(Point point) {
84   - this.point = point;
85   - }
86   -
87   - public Float getRadius() {
88   - return radius;
89   - }
90   -
91   - public void setRadius(Float radius) {
92   - this.radius = radius;
93   - }
94   -
95   - public Polygon getPolygon() {
96   - return polygon;
97   - }
98   -
99   - public void setPolygon(Polygon polygon) {
100   - this.polygon = polygon;
101   - }
102   -
103   - public String getLineCode() {
104   - return lineCode;
105   - }
106   -
107   - public void setLineCode(String lineCode) {
108   - this.lineCode = lineCode;
109   - }
110   -
111   - public int getDirections() {
112   - return directions;
113   - }
114   -
115   - public void setDirections(int directions) {
116   - this.directions = directions;
117   - }
118   -
119   - public StationRoute getNext() {
120   - return next;
121   - }
122   -
123   - public void setNext(StationRoute next) {
124   - this.next = next;
125   - }
126   -
127   - public StationRoute getPrve() {
128   - return prve;
129   - }
130   -
131   - public void setPrve(StationRoute prve) {
132   - this.prve = prve;
133   - }
134   -
135   - public String getMark() {
136   - return mark;
137   - }
138   -
139   - public void setMark(String mark) {
140   - this.mark = mark;
141   - }
142   -
143   - public String getName() {
144   - return name;
145   - }
146   -
147   - public void setName(String name) {
148   - this.name = name;
149   - }
150   -}
151   -
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +import com.vividsolutions.jts.geom.Point;
  4 +import com.vividsolutions.jts.geom.Polygon;
  5 +
  6 +/**
  7 + * Created by panzhao on 2016/12/23.
  8 + */
  9 +public class StationRoute {
  10 +
  11 + /**
  12 + * 线路编码
  13 + */
  14 + private String lineCode;
  15 +
  16 + /**
  17 + * 上下行
  18 + */
  19 + private int directions;
  20 +
  21 + /**
  22 + * 站点编码
  23 + */
  24 + private String code;
  25 +
  26 + /**
  27 + * 路由顺序
  28 + */
  29 + private int routeSort;
  30 +
  31 + /**
  32 + * 站点位置
  33 + */
  34 + private Point point;
  35 +
  36 + /**
  37 + * 圆形半径
  38 + */
  39 + private Float radius;
  40 +
  41 + /**
  42 + * 多边形电子围栏
  43 + */
  44 + private Polygon polygon;
  45 +
  46 + /**
  47 + * 站点标记
  48 + */
  49 + private String mark;
  50 +
  51 + /**
  52 + * 下一站
  53 + */
  54 + private StationRoute next;
  55 +
  56 + /**
  57 + * 上一站
  58 + */
  59 + private StationRoute prve;
  60 +
  61 + private String name;
  62 +
  63 + public String getCode() {
  64 + return code;
  65 + }
  66 +
  67 + public void setCode(String code) {
  68 + this.code = code;
  69 + }
  70 +
  71 + public int getRouteSort() {
  72 + return routeSort;
  73 + }
  74 +
  75 + public void setRouteSort(int routeSort) {
  76 + this.routeSort = routeSort;
  77 + }
  78 +
  79 + public Point getPoint() {
  80 + return point;
  81 + }
  82 +
  83 + public void setPoint(Point point) {
  84 + this.point = point;
  85 + }
  86 +
  87 + public Float getRadius() {
  88 + return radius;
  89 + }
  90 +
  91 + public void setRadius(Float radius) {
  92 + this.radius = radius;
  93 + }
  94 +
  95 + public Polygon getPolygon() {
  96 + return polygon;
  97 + }
  98 +
  99 + public void setPolygon(Polygon polygon) {
  100 + this.polygon = polygon;
  101 + }
  102 +
  103 + public String getLineCode() {
  104 + return lineCode;
  105 + }
  106 +
  107 + public void setLineCode(String lineCode) {
  108 + this.lineCode = lineCode;
  109 + }
  110 +
  111 + public int getDirections() {
  112 + return directions;
  113 + }
  114 +
  115 + public void setDirections(int directions) {
  116 + this.directions = directions;
  117 + }
  118 +
  119 + public StationRoute getNext() {
  120 + return next;
  121 + }
  122 +
  123 + public void setNext(StationRoute next) {
  124 + this.next = next;
  125 + }
  126 +
  127 + public StationRoute getPrve() {
  128 + return prve;
  129 + }
  130 +
  131 + public void setPrve(StationRoute prve) {
  132 + this.prve = prve;
  133 + }
  134 +
  135 + public String getMark() {
  136 + return mark;
  137 + }
  138 +
  139 + public void setMark(String mark) {
  140 + this.mark = mark;
  141 + }
  142 +
  143 + public String getName() {
  144 + return name;
  145 + }
  146 +
  147 + public void setName(String name) {
  148 + this.name = name;
  149 + }
  150 +}
  151 +
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
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   -}
  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
1   -package com.bsth.data.gpsdata.arrival.handlers;
2   -
3   -import com.bsth.data.LineConfigData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.SignalHandle;
7   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
8   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
9   -import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
10   -import com.bsth.data.schedule.DayOfSchedule;
11   -import com.bsth.entity.realcontrol.LineConfig;
12   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
13   -import com.bsth.service.directive.DirectiveService;
14   -import com.bsth.websocket.handler.SendUtils;
15   -import org.slf4j.Logger;
16   -import org.slf4j.LoggerFactory;
17   -import org.springframework.beans.factory.annotation.Autowired;
18   -import org.springframework.stereotype.Component;
19   -
20   -import java.util.List;
21   -
22   -/**
23   - * 进出站动作处理
24   - * Created by panzhao on 2016/12/27.
25   - */
26   -@Component
27   -public class InOutStationSignalHandle extends SignalHandle{
28   -
29   - Logger logger = LoggerFactory.getLogger(this.getClass());
30   -
31   - @Autowired
32   - DayOfSchedule dayOfSchedule;
33   -
34   - @Autowired
35   - LineConfigData lineConfigData;
36   -
37   - @Autowired
38   - SendUtils sendUtils;
39   -
40   - @Autowired
41   - DirectiveService directiveService;
42   -
43   - @Override
44   - public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
45   -
46   - if(isNotEmpty(prevs)){
47   - GpsEntity prev = prevs.getTail();
48   - if(isOutStation(gps, prev))
49   - outStation(gps, prev);
50   -
51   -
52   - if(isInStation(gps, prev))
53   - inStation(gps, prev);
54   - }
55   -
56   - return true;
57   - }
58   -
59   - private boolean isOutStation(GpsEntity gps, GpsEntity prev){
60   - //从站内到站外
61   - if(prev.getInstation() > 0 && gps.getInstation() == 0)
62   - return true;
63   -
64   - //从站内到另一个站内
65   - if(prev.getInstation() > 0 && gps.getInstation() > 0
66   - && !prev.getStopNo().equals(gps.getStopNo()))
67   - return true;
68   - return false;
69   - }
70   -
71   - private boolean isInStation(GpsEntity gps, GpsEntity prev){
72   - //从站外到站内
73   - if(prev.getInstation() == 0 && gps.getInstation() > 0
74   - /*&& !prev.getStopNo().equals(gps.getStopNo())*/){
75   - return true;
76   - }
77   -
78   - //从站内到另一个站内
79   - if(prev.getInstation() > 0 && gps.getInstation() > 0
80   - && !prev.getStopNo().equals(gps.getStopNo()))
81   - return true;
82   - return false;
83   - }
84   -
85   - /**
86   - * 出站
87   - * @param gps 当前点
88   - * @param prev 上一个点
89   - */
90   - private void outStation(GpsEntity gps, GpsEntity prev) {
91   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
92   - String qdzCode = sch.getQdzCode();
93   -
94   -
95   - //if(sch.getFcsjActual() != )
96   -
97   - //起点发车
98   - if(qdzCode != null && prev.getStopNo().equals(qdzCode)
99   - && !willDepart(gps, prev, sch)){
100   -
101   - sch.setFcsjActualAll(gps.getTimestamp());
102   - //通知客户端
103   - sendUtils.sendFcsj(sch);
104   - //持久化
105   - dayOfSchedule.save(sch);
106   -
107   - //出站既出场
108   - outStationAndOutPark(sch);
109   - logger.info("班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
110   - }
111   - }
112   -
113   - private void outStationAndOutPark(ScheduleRealInfo sch){
114   - LineConfig config = lineConfigData.get(sch.getXlBm());
115   - if (config != null && config.getOutConfig() == 2) {
116   - //出站既出场
117   - ScheduleRealInfo schPrev = dayOfSchedule.prev(sch);
118   - if (schPrev != null && schPrev.getBcType().equals("out")) {
119   - schPrev.setFcsjActualAll(sch.getFcsjActual());
120   - schPrev.setZdsjActualAll(sch.getFcsjActual());
121   - }
122   - }
123   - }
124   -
125   - /**
126   - * 进站
127   - * @param gps 当前点
128   - * @param prev 上一个点
129   - */
130   - private void inStation(GpsEntity gps, GpsEntity prev){
131   - ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
132   - String zdzCode = sch.getZdzCode();
133   -
134   - if(zdzCode != null && gps.getStopNo().equals(zdzCode)){
135   -
136   - sch.setZdsjActualAll(gps.getTimestamp());
137   - //已完成班次数
138   - int doneSum = dayOfSchedule.doneSum(sch.getClZbh());
139   - ScheduleRealInfo next = dayOfSchedule.next(sch);
140   - //通知客户端
141   - sendUtils.sendZdsj(sch, next, doneSum);
142   - //持久化
143   - dayOfSchedule.save(sch);
144   - //下发调度指令
145   - //directiveService.send60Dispatch(next, doneSum, "到站@系统");
146   -
147   - //准备执行下一个班次
148   - if (next != null) {
149   - next.setQdzArrDatesj(sch.getZdsjActual());
150   - dayOfSchedule.addExecPlan(next);
151   -
152   - //进站既进场
153   - inStationAndInPark(sch, next);
154   -
155   - //将gps转换为下一个班次走向的站内信号
156   - int updown = Integer.parseInt(next.getXlDir());
157   - List<StationRoute> srs = GeoCacheData.getStationRoute(next.getXlBm(), updown);
158   - StationRoute station = GeoUtils.gpsInStation(gps, srs);
159   - if (station != null) {
160   - gps.setUpDown(updown);
161   - gps.setStopNo(station.getCode());
162   - }
163   - }
164   - }
165   - /* //如果出场班次计划终点时间5分钟后还未完成,检查一下车辆轨迹,是否已经在执行线路上班次
166   - else if(sch.getBcType().equals("out")
167   - && sch.getZdsj() != null
168   - && gps.getTimestamp() - sch.getZdsjT() >= 1000 * 60 * 5){
169   - logger.info("出场班次计划终点时间5分钟后还未完成");
170   -
171   - }*/
172   - }
173   -
174   - /**
175   - * 进站既进场
176   - * @param sch
177   - */
178   - private void inStationAndInPark(ScheduleRealInfo sch, ScheduleRealInfo next){
179   - LineConfig config = lineConfigData.get(sch.getXlBm());
180   - if (next.getBcType().equals("in") &&
181   - config != null && config.getOutConfig() == 2) {
182   - next.setFcsjActualAll(sch.getZdsjActual());
183   - next.setZdsjActualAll(sch.getZdsjActual());
184   - }
185   - }
186   -
187   - /**
188   - * 发车漂移判定(这里出现的误判,由车辆到达中途站的时候补偿)
189   - * @param gps
190   - * @param prev
191   - * @param task
192   - * @return
193   - */
194   - private boolean willDepart(GpsEntity gps, GpsEntity prev, Object task){
195   -
196   -/* ScheduleRealInfo sch = (ScheduleRealInfo) task;
197   - ScheduleRealInfo prevTask = dayOfSchedule.prev(sch);
198   - if(prevTask == null || prevTask.getBcType().equals("out"))
199   - return false;
200   -
201   - //计划停站时间
202   - int stopTimePlan = (int) (sch.getDfsjT() - prevTask.getZdsjT());
203   -
204   - if(stopTimePlan < 1000 * 60 * 10)
205   - return false;
206   -
207   - //实际停站时间
208   - if(prevTask.getZdsjActual() != null){
209   - int actualTime = (int) (gps.getTimestamp() - prevTask.getZdsjActualTime());
210   -
211   - if(actualTime < stopTimePlan * 0.8){
212   - logger.info("漂移判定");
213   -
214   - return true;
215   - }
216   - }*/
217   - return false;
218   - }
219   -}
  1 +package com.bsth.data.gpsdata.arrival.handlers;
  2 +
  3 +import com.bsth.data.LineConfigData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.arrival.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
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   -}
  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
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   -}
  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
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   -}
  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/arrival/utils/CircleQueue.java
1   -package com.bsth.data.gpsdata.arrival.utils;
2   -
3   -import java.util.Arrays;
4   -
5   -/**
6   - * 循环队列
7   - * Created by panzhao on 2016/12/23.
8   - */
9   -public class CircleQueue<T> {
10   -
11   - /**
12   - * (循环队列)数组的容量
13   - */
14   - public int capacity;
15   -
16   - /**
17   - * 数组:保存循环队列的元素
18   - */
19   - public Object[] elementData;
20   -
21   - /**
22   - * 头
23   - */
24   - public int head = 0;
25   -
26   - /**
27   - * 尾
28   - */
29   - public int tail = 0;
30   -
31   - /**
32   - * 以指定长度的数组来创建循环队列
33   - *
34   - * @param initSize
35   - */
36   - public CircleQueue(final int initSize) {
37   - capacity = initSize;
38   - elementData = new Object[capacity];
39   - }
40   -
41   - /**
42   - * 获取循环队列的大小
43   - */
44   - public int size() {
45   - if (isEmpty()) {
46   - return 0;
47   - } else if (isFull()) {
48   - return capacity;
49   - } else {
50   - return tail + 1;
51   - }
52   - }
53   -
54   - /**
55   - * 插入队尾一个元素
56   - */
57   - public void add(final T element) {
58   - if (isEmpty()) {
59   - elementData[0] = element;
60   - } else if (isFull()) {
61   - elementData[head] = element;
62   - head++;
63   - tail++;
64   - head = head == capacity ? 0 : head;
65   - tail = tail == capacity ? 0 : tail;
66   - } else {
67   - elementData[tail + 1] = element;
68   - tail++;
69   - }
70   - }
71   -
72   - public boolean isEmpty() {
73   - return tail == head && tail == 0 && elementData[tail] == null;
74   - }
75   -
76   - public boolean isFull() {
77   - return head != 0 && head - tail == 1 || head == 0 && tail == capacity - 1;
78   - }
79   -
80   - public void clear() {
81   - Arrays.fill(elementData, null);
82   - head = 0;
83   - tail = 0;
84   - }
85   -
86   - /**
87   - * @return 取 循环队列里的值(先进的index=0)
88   - */
89   - public Object[] getQueue() {
90   - final Object[] elementDataSort;
91   - final Object[] elementDataCopy = elementData.clone();
92   - if (isEmpty()) {
93   - elementDataSort = new Object[0];
94   - } else if (isFull()) {
95   - elementDataSort = new Object[capacity];
96   - int indexMax = capacity;
97   - int indexSort = 0;
98   - for (int i = head; i < indexMax;) {
99   - elementDataSort[indexSort] = elementDataCopy[i];
100   - indexSort++;
101   - i++;
102   - if (i == capacity) {
103   - i = 0;
104   - indexMax = head;
105   - }
106   - }
107   - } else {
108   - elementDataSort = new Object[tail];
109   - for (int i = 0; i < tail; i++) {
110   - elementDataSort[i] = elementDataCopy[i];
111   - }
112   - }
113   - return elementDataSort;
114   - }
115   -
116   - /**
117   - * 取最后一个值
118   - * @return
119   - */
120   - public T getTail(){
121   - return elementData[tail] == null?null:(T)elementData[tail];
122   - }
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import java.util.Arrays;
  4 +
  5 +/**
  6 + * 循环队列
  7 + * Created by panzhao on 2016/12/23.
  8 + */
  9 +public class CircleQueue<T> {
  10 +
  11 + /**
  12 + * (循环队列)数组的容量
  13 + */
  14 + public int capacity;
  15 +
  16 + /**
  17 + * 数组:保存循环队列的元素
  18 + */
  19 + public Object[] elementData;
  20 +
  21 + /**
  22 + * 头
  23 + */
  24 + public int head = 0;
  25 +
  26 + /**
  27 + * 尾
  28 + */
  29 + public int tail = 0;
  30 +
  31 + /**
  32 + * 以指定长度的数组来创建循环队列
  33 + *
  34 + * @param initSize
  35 + */
  36 + public CircleQueue(final int initSize) {
  37 + capacity = initSize;
  38 + elementData = new Object[capacity];
  39 + }
  40 +
  41 + /**
  42 + * 获取循环队列的大小
  43 + */
  44 + public int size() {
  45 + if (isEmpty()) {
  46 + return 0;
  47 + } else if (isFull()) {
  48 + return capacity;
  49 + } else {
  50 + return tail + 1;
  51 + }
  52 + }
  53 +
  54 + /**
  55 + * 插入队尾一个元素
  56 + */
  57 + public void add(final T element) {
  58 + if (isEmpty()) {
  59 + elementData[0] = element;
  60 + } else if (isFull()) {
  61 + elementData[head] = element;
  62 + head++;
  63 + tail++;
  64 + head = head == capacity ? 0 : head;
  65 + tail = tail == capacity ? 0 : tail;
  66 + } else {
  67 + elementData[tail + 1] = element;
  68 + tail++;
  69 + }
  70 + }
  71 +
  72 + public boolean isEmpty() {
  73 + return tail == head && tail == 0 && elementData[tail] == null;
  74 + }
  75 +
  76 + public boolean isFull() {
  77 + return head != 0 && head - tail == 1 || head == 0 && tail == capacity - 1;
  78 + }
  79 +
  80 + public void clear() {
  81 + Arrays.fill(elementData, null);
  82 + head = 0;
  83 + tail = 0;
  84 + }
  85 +
  86 + /**
  87 + * @return 取 循环队列里的值(先进的index=0)
  88 + */
  89 + public Object[] getQueue() {
  90 + final Object[] elementDataSort;
  91 + final Object[] elementDataCopy = elementData.clone();
  92 + if (isEmpty()) {
  93 + elementDataSort = new Object[0];
  94 + } else if (isFull()) {
  95 + elementDataSort = new Object[capacity];
  96 + int indexMax = capacity;
  97 + int indexSort = 0;
  98 + for (int i = head; i < indexMax;) {
  99 + elementDataSort[indexSort] = elementDataCopy[i];
  100 + indexSort++;
  101 + i++;
  102 + if (i == capacity) {
  103 + i = 0;
  104 + indexMax = head;
  105 + }
  106 + }
  107 + } else {
  108 + elementDataSort = new Object[tail];
  109 + for (int i = 0; i < tail; i++) {
  110 + elementDataSort[i] = elementDataCopy[i];
  111 + }
  112 + }
  113 + return elementDataSort;
  114 + }
  115 +
  116 + /**
  117 + * 取最后一个值
  118 + * @return
  119 + */
  120 + public T getTail(){
  121 + return elementData[tail] == null?null:(T)elementData[tail];
  122 + }
123 123 }
124 124 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
1   -package com.bsth.data.gpsdata.arrival.utils;
2   -
3   -import com.bsth.data.gpsdata.GpsEntity;
4   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
5   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
6   -import com.vividsolutions.jts.geom.Coordinate;
7   -import com.vividsolutions.jts.geom.GeometryFactory;
8   -import com.vividsolutions.jts.geom.Point;
9   -import com.vividsolutions.jts.geom.Polygon;
10   -
11   -import java.util.List;
12   -import java.util.Map;
13   -import java.util.Set;
14   -
15   -/**
16   - * Created by panzhao on 2016/12/23.
17   - */
18   -public class GeoUtils {
19   -
20   - private final static double EARTHRADIUS = 6378137;
21   -
22   - private static GeometryFactory geometryFactory = new GeometryFactory();
23   - /**
24   - * gps是否在路由上的某个站内
25   - *
26   - * @param gps
27   - * @param srs
28   - * @return
29   - */
30   - public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) {
31   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
32   - double min = -1, distance, distance2;
33   - StationRoute stationRoute = null;
34   -
35   - for (StationRoute sr : srs) {
36   - if (sr.getPolygon() == null) {
37   - //圆形
38   - distance = getDistance(sr.getPoint(), point);//sr.getPoint().distance(point);
39   -
40   - if (distance > sr.getRadius())
41   - continue;
42   -
43   - if (min > distance || min == -1) {
44   - min = distance;
45   - stationRoute = sr;
46   - }
47   - } else {
48   - //多边形
49   - if (sr.getPolygon().contains(point)) {
50   - stationRoute = sr;
51   - break;
52   - }
53   - }
54   - }
55   - return stationRoute;
56   - }
57   -
58   - public static double getDistance(Point p1, Point p2) {
59   - double lng1 = getLoop(p1.getY(), -180, 180), lat1 = getRange(
60   - p1.getX(), -74, 74);
61   - double lng2 = getLoop(p2.getY(), -180, 180), lat2 = getRange(
62   - p2.getX(), -74, 74);
63   -
64   - double x1, x2, y1, y2;
65   - x1 = degreeToRad(lng1);
66   - y1 = degreeToRad(lat1);
67   - x2 = degreeToRad(lng2);
68   - y2 = degreeToRad(lat2);
69   - return EARTHRADIUS
70   - * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1)
71   - * Math.cos(y2) * Math.cos(x2 - x1)));
72   - }
73   -
74   - private static double getLoop(double v, double a, double b) {
75   - while (v > b) {
76   - v -= b - a;
77   - }
78   - while (v < a) {
79   - v += b - a;
80   - }
81   - return v;
82   - }
83   -
84   - private static double getRange(double v, double a, double b) {
85   - v = Math.min(Math.max(v, a), b);
86   - return v;
87   - }
88   -
89   - private static double degreeToRad(double degree) {
90   - return Math.PI * degree / 180;
91   - }
92   -
93   -
94   - /**
95   - * gps 是否在某个停车场内
96   - * @param gps
97   - * @return
98   - */
99   - public static String gpsInCarpark(GpsEntity gps){
100   - Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
101   -
102   - Map<String, Polygon> carparkMap = GeoCacheData.tccMap;
103   - Set<String> codes = carparkMap.keySet();
104   - Polygon polygon;
105   - for(String code : codes){
106   - polygon = carparkMap.get(code);
107   - if(point.within(polygon)){
108   - return code;
109   - }
110   - }
111   - return null;
112   - }
113   -
114   - /**
115   - * 是否是有效的连续点
116   - * @param prevGps
117   - * @param gps
118   - * @return
119   - */
120   - public static boolean overdue(GpsEntity prevGps, GpsEntity gps) {
121   - return gps.getTimestamp() - prevGps.getTimestamp() < 120000;
122   - }
123   -}
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  5 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  6 +import com.vividsolutions.jts.geom.Coordinate;
  7 +import com.vividsolutions.jts.geom.GeometryFactory;
  8 +import com.vividsolutions.jts.geom.Point;
  9 +import com.vividsolutions.jts.geom.Polygon;
  10 +
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +import java.util.Set;
  14 +
  15 +/**
  16 + * Created by panzhao on 2016/12/23.
  17 + */
  18 +public class GeoUtils {
  19 +
  20 + private final static double EARTHRADIUS = 6378137;
  21 +
  22 + private static GeometryFactory geometryFactory = new GeometryFactory();
  23 + /**
  24 + * gps是否在路由上的某个站内
  25 + *
  26 + * @param gps
  27 + * @param srs
  28 + * @return
  29 + */
  30 + public static StationRoute gpsInStation(GpsEntity gps, List<StationRoute> srs) {
  31 + Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  32 + double min = -1, distance, distance2;
  33 + StationRoute stationRoute = null;
  34 +
  35 + for (StationRoute sr : srs) {
  36 + if (sr.getPolygon() == null) {
  37 + //圆形
  38 + distance = getDistance(sr.getPoint(), point);//sr.getPoint().distance(point);
  39 +
  40 + if (distance > sr.getRadius())
  41 + continue;
  42 +
  43 + if (min > distance || min == -1) {
  44 + min = distance;
  45 + stationRoute = sr;
  46 + }
  47 + } else {
  48 + //多边形
  49 + if (sr.getPolygon().contains(point)) {
  50 + stationRoute = sr;
  51 + break;
  52 + }
  53 + }
  54 + }
  55 + return stationRoute;
  56 + }
  57 +
  58 + public static double getDistance(Point p1, Point p2) {
  59 + double lng1 = getLoop(p1.getY(), -180, 180), lat1 = getRange(
  60 + p1.getX(), -74, 74);
  61 + double lng2 = getLoop(p2.getY(), -180, 180), lat2 = getRange(
  62 + p2.getX(), -74, 74);
  63 +
  64 + double x1, x2, y1, y2;
  65 + x1 = degreeToRad(lng1);
  66 + y1 = degreeToRad(lat1);
  67 + x2 = degreeToRad(lng2);
  68 + y2 = degreeToRad(lat2);
  69 + return EARTHRADIUS
  70 + * Math.acos((Math.sin(y1) * Math.sin(y2) + Math.cos(y1)
  71 + * Math.cos(y2) * Math.cos(x2 - x1)));
  72 + }
  73 +
  74 + private static double getLoop(double v, double a, double b) {
  75 + while (v > b) {
  76 + v -= b - a;
  77 + }
  78 + while (v < a) {
  79 + v += b - a;
  80 + }
  81 + return v;
  82 + }
  83 +
  84 + private static double getRange(double v, double a, double b) {
  85 + v = Math.min(Math.max(v, a), b);
  86 + return v;
  87 + }
  88 +
  89 + private static double degreeToRad(double degree) {
  90 + return Math.PI * degree / 180;
  91 + }
  92 +
  93 +
  94 + /**
  95 + * gps 是否在某个停车场内
  96 + * @param gps
  97 + * @return
  98 + */
  99 + public static String gpsInCarpark(GpsEntity gps){
  100 + Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon()));
  101 +
  102 + Map<String, Polygon> carparkMap = GeoCacheData.tccMap;
  103 + Set<String> codes = carparkMap.keySet();
  104 + Polygon polygon;
  105 + for(String code : codes){
  106 + polygon = carparkMap.get(code);
  107 + if(point.within(polygon)){
  108 + return code;
  109 + }
  110 + }
  111 + return null;
  112 + }
  113 +
  114 + /**
  115 + * 是否是有效的连续点
  116 + * @param prevGps
  117 + * @param gps
  118 + * @return
  119 + */
  120 + public static boolean overdue(GpsEntity prevGps, GpsEntity gps) {
  121 + return gps.getTimestamp() - prevGps.getTimestamp() < 120000;
  122 + }
  123 +}
... ...
src/main/java/com/bsth/data/gpsdata/arrival/utils/StationRouteComp.java
1   -package com.bsth.data.gpsdata.arrival.utils;
2   -
3   -import com.bsth.data.gpsdata.arrival.entity.StationRoute;
4   -
5   -import java.util.Comparator;
6   -
7   -/**
8   - * Created by panzhao on 2016/12/24.
9   - */
10   -public class StationRouteComp implements Comparator<StationRoute>{
11   - @Override
12   - public int compare(StationRoute s1, StationRoute s2) {
13   - return s1.getRouteSort() - s2.getRouteSort();
14   - }
15   -}
  1 +package com.bsth.data.gpsdata.arrival.utils;
  2 +
  3 +import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  4 +
  5 +import java.util.Comparator;
  6 +
  7 +/**
  8 + * Created by panzhao on 2016/12/24.
  9 + */
  10 +public class StationRouteComp implements Comparator<StationRoute>{
  11 + @Override
  12 + public int compare(StationRoute s1, StationRoute s2) {
  13 + return s1.getRouteSort() - s2.getRouteSort();
  14 + }
  15 +}
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
1   -package com.bsth.data.gpsdata.recovery;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.data.gpsdata.GpsEntity;
5   -import com.bsth.data.gpsdata.arrival.GeoCacheData;
6   -import com.bsth.data.gpsdata.arrival.handlers.*;
7   -import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
8   -import com.bsth.util.db.DBUtils_MS;
9   -import com.google.common.collect.ArrayListMultimap;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.beans.BeansException;
13   -import org.springframework.context.ApplicationContext;
14   -import org.springframework.context.ApplicationContextAware;
15   -import org.springframework.jdbc.core.JdbcTemplate;
16   -import org.springframework.jdbc.core.RowMapper;
17   -import org.springframework.stereotype.Component;
18   -
19   -import java.sql.ResultSet;
20   -import java.sql.SQLException;
21   -import java.util.*;
22   -import java.util.concurrent.CountDownLatch;
23   -import java.util.concurrent.ExecutorService;
24   -import java.util.concurrent.Executors;
25   -
26   -/**
27   - * gps数据恢复
28   - * Created by panzhao on 2016/12/24.
29   - */
30   -@Component
31   -public class GpsDataRecovery implements ApplicationContextAware{
32   -
33   - static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
34   -
35   - public static boolean run;
36   -
37   - static ExecutorService threadPool = Executors.newFixedThreadPool(10);
38   -
39   - static OfflineSignalHandle offlineSignalHandle;
40   - static CorrectSignalHandle correctSignalHandle;
41   - static StationInsideHandle stationInsideHandle;
42   - static InOutStationSignalHandle inOutStationSignalHandle;
43   - static ReverseSignalHandle reverseSignalHandle;
44   -
45   - public void recovery() {
46   - List<GpsEntity> list = loadData();
47   -
48   - //按车辆分组数据
49   - ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create();
50   - for (GpsEntity gps : list) {
51   - if(gps.getNbbm() != null)
52   - listMap.put(gps.getNbbm(), gps);
53   - }
54   -
55   -
56   - Set<String> keys = listMap.keySet();
57   -
58   - CountDownLatch count = new CountDownLatch(keys.size());
59   - GpsComp comp = new GpsComp();
60   - for (String nbbm : keys) {
61   - Collections.sort(listMap.get(nbbm), comp);
62   - threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
63   - }
64   -
65   - try {
66   - count.await();
67   - run = false;
68   - logger.info("数据恢复完成....");
69   - } catch (InterruptedException e) {
70   - logger.error("", e);
71   - }
72   - }
73   -
74   - /**
75   - * 加载当天的gps数据
76   - *
77   - * @return
78   - */
79   - public List<GpsEntity> loadData() {
80   - Calendar calendar = Calendar.getInstance();
81   - int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
82   -
83   - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear;
84   - JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
85   -
86   - List<GpsEntity> list =
87   - jdbcTemplate.query(sql, new RowMapper<GpsEntity>() {
88   - @Override
89   - public GpsEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
90   - GpsEntity gps = new GpsEntity();
91   -
92   - gps.setDeviceId(rs.getString("DEVICE_ID"));
93   - gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
94   - gps.setSpeed(rs.getFloat("SPEED_GPS"));
95   - gps.setLat(rs.getFloat("LAT"));
96   - gps.setLon(rs.getFloat("LON"));
97   - gps.setLineId(rs.getString("LINE_ID"));
98   - gps.setTimestamp(rs.getLong("TS"));
99   - gps.setUpDown(getUpOrDown(rs.getLong("SERVICE_STATE")));
100   - return gps;
101   - }
102   - });
103   - return list;
104   - }
105   -
106   - /**
107   - * 王通 2016/6/29 9:23:24 获取车辆线路上下行
108   - *
109   - * @return -1无效 0上行 1下行
110   - */
111   - public static int getUpOrDown(long serviceState) {
112   - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
113   - || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
114   - return -1;
115   - return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
116   - }
117   -
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   - }
134   -
135   - public static class RecoveryThread implements Runnable{
136   - List<GpsEntity> list;
137   - CountDownLatch count;
138   -
139   - RecoveryThread(List<GpsEntity> list, CountDownLatch count){
140   - this.list = list;
141   - this.count = count;
142   - }
143   - @Override
144   - public void run() {
145   - try {
146   - //循环gps恢复数据
147   - CircleQueue<GpsEntity> prevs;
148   -
149   - for(GpsEntity gps : list){
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);
163   - }
164   - }catch (Exception e){
165   - logger.error("", e);
166   - }
167   - finally {
168   - count.countDown();
169   - }
170   - }
171   - }
  1 +package com.bsth.data.gpsdata.recovery;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.gpsdata.GpsEntity;
  5 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  6 +import com.bsth.data.gpsdata.arrival.handlers.*;
  7 +import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
  8 +import com.bsth.util.db.DBUtils_MS;
  9 +import com.google.common.collect.ArrayListMultimap;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.BeansException;
  13 +import org.springframework.context.ApplicationContext;
  14 +import org.springframework.context.ApplicationContextAware;
  15 +import org.springframework.jdbc.core.JdbcTemplate;
  16 +import org.springframework.jdbc.core.RowMapper;
  17 +import org.springframework.stereotype.Component;
  18 +
  19 +import java.sql.ResultSet;
  20 +import java.sql.SQLException;
  21 +import java.util.*;
  22 +import java.util.concurrent.CountDownLatch;
  23 +import java.util.concurrent.ExecutorService;
  24 +import java.util.concurrent.Executors;
  25 +
  26 +/**
  27 + * gps数据恢复
  28 + * Created by panzhao on 2016/12/24.
  29 + */
  30 +@Component
  31 +public class GpsDataRecovery implements ApplicationContextAware{
  32 +
  33 + static Logger logger = LoggerFactory.getLogger(GpsDataRecovery.class);
  34 +
  35 + public static boolean run;
  36 +
  37 + static ExecutorService threadPool = Executors.newFixedThreadPool(10);
  38 +
  39 + static OfflineSignalHandle offlineSignalHandle;
  40 + static CorrectSignalHandle correctSignalHandle;
  41 + static StationInsideHandle stationInsideHandle;
  42 + static InOutStationSignalHandle inOutStationSignalHandle;
  43 + static ReverseSignalHandle reverseSignalHandle;
  44 +
  45 + public void recovery() {
  46 + List<GpsEntity> list = loadData();
  47 +
  48 + //按车辆分组数据
  49 + ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create();
  50 + for (GpsEntity gps : list) {
  51 + if(gps.getNbbm() != null)
  52 + listMap.put(gps.getNbbm(), gps);
  53 + }
  54 +
  55 +
  56 + Set<String> keys = listMap.keySet();
  57 +
  58 + CountDownLatch count = new CountDownLatch(keys.size());
  59 + GpsComp comp = new GpsComp();
  60 + for (String nbbm : keys) {
  61 + Collections.sort(listMap.get(nbbm), comp);
  62 + threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
  63 + }
  64 +
  65 + try {
  66 + count.await();
  67 + run = false;
  68 + logger.info("数据恢复完成....");
  69 + } catch (InterruptedException e) {
  70 + logger.error("", e);
  71 + }
  72 + }
  73 +
  74 + /**
  75 + * 加载当天的gps数据
  76 + *
  77 + * @return
  78 + */
  79 + public List<GpsEntity> loadData() {
  80 + Calendar calendar = Calendar.getInstance();
  81 + int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
  82 +
  83 + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE from bsth_c_gps_info where days_year=" + dayOfYear;
  84 + JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
  85 +
  86 + List<GpsEntity> list =
  87 + jdbcTemplate.query(sql, new RowMapper<GpsEntity>() {
  88 + @Override
  89 + public GpsEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
  90 + GpsEntity gps = new GpsEntity();
  91 +
  92 + gps.setDeviceId(rs.getString("DEVICE_ID"));
  93 + gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId()));
  94 + gps.setSpeed(rs.getFloat("SPEED_GPS"));
  95 + gps.setLat(rs.getFloat("LAT"));
  96 + gps.setLon(rs.getFloat("LON"));
  97 + gps.setLineId(rs.getString("LINE_ID"));
  98 + gps.setTimestamp(rs.getLong("TS"));
  99 + gps.setUpDown(getUpOrDown(rs.getLong("SERVICE_STATE")));
  100 + return gps;
  101 + }
  102 + });
  103 + return list;
  104 + }
  105 +
  106 + /**
  107 + * 王通 2016/6/29 9:23:24 获取车辆线路上下行
  108 + *
  109 + * @return -1无效 0上行 1下行
  110 + */
  111 + public static int getUpOrDown(long serviceState) {
  112 + if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
  113 + || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
  114 + return -1;
  115 + return (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
  116 + }
  117 +
  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 + }
  134 +
  135 + public static class RecoveryThread implements Runnable{
  136 + List<GpsEntity> list;
  137 + CountDownLatch count;
  138 +
  139 + RecoveryThread(List<GpsEntity> list, CountDownLatch count){
  140 + this.list = list;
  141 + this.count = count;
  142 + }
  143 + @Override
  144 + public void run() {
  145 + try {
  146 + //循环gps恢复数据
  147 + CircleQueue<GpsEntity> prevs;
  148 +
  149 + for(GpsEntity gps : list){
  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);
  163 + }
  164 + }catch (Exception e){
  165 + logger.error("", e);
  166 + }
  167 + finally {
  168 + count.countDown();
  169 + }
  170 + }
  171 + }
172 172 }
173 173 \ No newline at end of file
... ...
src/main/java/com/bsth/service/excep/impl/OfflineServiceImpl.java
... ... @@ -46,23 +46,33 @@ public class OfflineServiceImpl implements OfflineService {
46 46 Object line=map.get("line");
47 47 Object nbbm=map.get("nbbm");
48 48 Object updown=map.get("updown");
49   -
  49 + Object date=map.get("date");
50 50  
51 51 if(line!=null){
52   - if(line.toString()!="")
53   - sql +=" and line="+line;
  52 + sql +=" and line like'%"+line.toString()+"%'";
54 53 }
55 54  
56 55 if(nbbm!=null){
57   - if(nbbm.toString()!="")
58   - sql +=" and vehicle like '%"+nbbm+"%'";
  56 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
59 57 }
60 58  
61 59 if(updown!=null){
62   - if(updown.toString() !="")
63   - sql +="and up_down ="+updown;
  60 + sql +="and up_down like '%"+updown.toString()+"%'";
  61 + }
  62 + if(date!=null){
  63 + if (date.toString().length()>0) {
  64 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  65 + try {
  66 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  67 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  68 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  69 + } catch (ParseException e) {
  70 + // TODO Auto-generated catch block
  71 + e.printStackTrace();
  72 + }
  73 + }
  74 +
64 75 }
65   -
66 76 sql +=" order by id limit ?,?";
67 77  
68 78 try {
... ... @@ -118,19 +128,32 @@ public class OfflineServiceImpl implements OfflineService {
118 128 Object nbbm=map.get("nbbm");
119 129 Object updown=map.get("updown");
120 130  
  131 + Object date=map.get("date");
  132 +
121 133 if(line!=null){
122   - if(line.toString()!="")
123   - sql +=" and line="+line;
  134 + sql +=" and line like'%"+line.toString()+"%'";
124 135 }
125 136  
126 137 if(nbbm!=null){
127   - if(nbbm.toString()!="")
128   - sql +=" and vehicle like '%"+nbbm+"%'";
  138 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
129 139 }
130 140  
131 141 if(updown!=null){
132   - if(updown.toString() !="")
133   - sql +="and up_down ="+updown;
  142 + sql +="and up_down like '%"+updown.toString()+"%'";
  143 + }
  144 + if(date!=null){
  145 + if (date.toString().length()>0) {
  146 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  147 + try {
  148 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  149 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  150 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  151 + } catch (ParseException e) {
  152 + // TODO Auto-generated catch block
  153 + e.printStackTrace();
  154 + }
  155 + }
  156 +
134 157 }
135 158  
136 159 Connection conn = null;
... ...
src/main/java/com/bsth/service/excep/impl/OutboundServiceImpl.java
... ... @@ -36,23 +36,33 @@ public class OutboundServiceImpl implements OutboundService{
36 36 Object line=map.get("line");
37 37 Object nbbm=map.get("nbbm");
38 38 Object updown=map.get("updown");
  39 + Object date=map.get("date");
39 40  
40   -
41 41 if(line!=null){
42   - if(line.toString()!="")
43   - sql +=" and line="+line;
  42 + sql +=" and line like'%"+line.toString()+"%'";
44 43 }
45 44  
46 45 if(nbbm!=null){
47   - if(nbbm.toString()!="")
48   - sql +=" and vehicle like '%"+nbbm+"%'";
  46 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
49 47 }
50 48  
51 49 if(updown!=null){
52   - if(updown.toString() !="")
53   - sql +="and up_down ="+updown;
  50 + sql +="and up_down like '%"+updown.toString()+"%'";
  51 + }
  52 + if(date!=null){
  53 + if (date.toString().length()>0) {
  54 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  55 + try {
  56 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  57 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  58 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  59 + } catch (ParseException e) {
  60 + // TODO Auto-generated catch block
  61 + e.printStackTrace();
  62 + }
  63 + }
  64 +
54 65 }
55   -
56 66 sql +=" order by id limit ?,?";
57 67  
58 68  
... ... @@ -102,20 +112,32 @@ public class OutboundServiceImpl implements OutboundService{
102 112 Object line=map.get("line");
103 113 Object nbbm=map.get("nbbm");
104 114 Object updown=map.get("updown");
105   -
  115 + Object date=map.get("date");
106 116 if(line!=null){
107   - if(line.toString()!="")
108   - sql +=" and line="+line;
  117 + sql +=" and line like '%"+line.toString()+"%'";
  118 +
109 119 }
110 120  
111 121 if(nbbm!=null){
112   - if(nbbm.toString()!="")
113   - sql +=" and vehicle like '%"+nbbm+"%'";
  122 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
114 123 }
115 124  
116 125 if(updown!=null){
117   - if(updown.toString() !="")
118   - sql +="and up_down ="+updown;
  126 + sql +=" and up_down like '%"+updown.toString()+"%'";
  127 + }
  128 + if(date!=null){
  129 + if (date.toString().length()>0) {
  130 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  131 + try {
  132 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  133 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  134 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  135 + } catch (ParseException e) {
  136 + // TODO Auto-generated catch block
  137 + e.printStackTrace();
  138 + }
  139 + }
  140 +
119 141 }
120 142 Connection conn = null;
121 143 PreparedStatement ps = null;
... ... @@ -214,7 +236,7 @@ public class OutboundServiceImpl implements OutboundService{
214 236 times=sdf.format(new Date());
215 237 }
216 238 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
217   - String times1=times+" 00:00:01";
  239 + String times1=times+" 00:00:00";
218 240 String times2=times+" 23:59:59";
219 241  
220 242 Connection conn = null;
... ...
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
... ... @@ -38,22 +38,34 @@ public class SpeedingServiceImpl implements SpeedingService {
38 38 Object line=map.get("line");
39 39 Object nbbm=map.get("nbbm");
40 40 Object updown=map.get("updown");
41   -
  41 + Object date=map.get("date");
42 42  
43 43 if(line!=null){
44   - if(line.toString()!="")
45   - sql +=" and line="+line;
  44 + sql +=" and line like'%"+line.toString()+"%'";
46 45 }
47 46  
48 47 if(nbbm!=null){
49   - if(nbbm.toString()!="")
50   - sql +=" and vehicle like '%"+nbbm+"%'";
  48 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
51 49 }
52 50  
53 51 if(updown!=null){
54   - if(updown.toString() !="")
55   - sql +="and up_down ="+updown;
  52 + sql +="and up_down like '%"+updown.toString()+"%'";
  53 + }
  54 + if(date!=null){
  55 + if (date.toString().length()>0) {
  56 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  57 + try {
  58 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  59 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  60 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  61 + } catch (ParseException e) {
  62 + // TODO Auto-generated catch block
  63 + e.printStackTrace();
  64 + }
  65 + }
  66 +
56 67 }
  68 +
57 69  
58 70 sql +=" order by id limit ?,?";
59 71  
... ... @@ -103,19 +115,32 @@ public class SpeedingServiceImpl implements SpeedingService {
103 115 Object nbbm=map.get("nbbm");
104 116 Object updown=map.get("updown");
105 117  
  118 + Object date=map.get("date");
  119 +
106 120 if(line!=null){
107   - if(line.toString()!="")
108   - sql +=" and line="+line;
  121 + sql +=" and line like'%"+line.toString()+"%'";
109 122 }
110 123  
111 124 if(nbbm!=null){
112   - if(nbbm.toString()!="")
113   - sql +=" and vehicle like '%"+nbbm+"%'";
  125 + sql +=" and vehicle like '%"+nbbm.toString()+"%'";
114 126 }
115 127  
116 128 if(updown!=null){
117   - if(updown.toString() !="")
118   - sql +="and up_down ="+updown;
  129 + sql +="and up_down like '%"+updown.toString()+"%'";
  130 + }
  131 + if(date!=null){
  132 + if (date.toString().length()>0) {
  133 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
  134 + try {
  135 + Long t1=sdf.parse(date.toString()+" 00:00:00").getTime();
  136 + Long t2=sdf.parse(date.toString()+" 23:59:59").getTime();
  137 + sql += " and timestamp >="+t1 +" and timestamp <="+t2;
  138 + } catch (ParseException e) {
  139 + // TODO Auto-generated catch block
  140 + e.printStackTrace();
  141 + }
  142 + }
  143 +
119 144 }
120 145 Connection conn = null;
121 146 PreparedStatement ps = null;
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -1212,7 +1212,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1212 1212 map.put("ljbc", ljbc);
1213 1213 map.put("sjbc", jhbc-cjbc+ljbc);
1214 1214 map.put("jcclc", jcclc);
1215   - map.put("zkslc", ksgl+jcclc);
  1215 + map.put("zkslc", format.format(ksgl+jcclc));
1216 1216 return map;
1217 1217 }
1218 1218  
... ...
src/main/java/com/bsth/service/report/ReportService.java
... ... @@ -24,6 +24,8 @@ public interface ReportService {
24 24 Map<String, Object> tbodyTime2(String line ,String ttinfo);
25 25  
26 26 List<Map<String, Object>> tbodyTime3(String line ,String ttinfo);
  27 +
  28 + List<Map<String, Object>> tbodyTime4(String line ,String ttinfo);
27 29 List<Map<String, Object>> tbodyTime5(String line ,String ttinfo);
28 30  
29 31 List<Map<String, Object>> getTtinfo(Map<String, Object> map);
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -451,21 +451,36 @@ public class ReportServiceImpl implements ReportService{
451 451 System.out.println(609360%60);
452 452 }
453 453 @Override
454   - public List<Map<String, Object>> tbodyTime3(String line, String date) {
  454 + public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) {
455 455 // TODO Auto-generated method stub
456 456 List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
457   - String sqlZd=" select qdz_name, count(cl_zbh) as cls , 'zqc' as lx from bsth_c_s_sp_info where "
458   - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' and bc_type='normal' "
459   - + " and fcsj>'06:31' and fcsj<'08:00' group by qdz_name union "
460   - + " select qdz_name, count(cl_zbh) as cls , 'wqc' as lx from bsth_c_s_sp_info "
461   - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' "
462   - + " and bc_type='normal' and fcsj>'16:01' and fcsj<'18:00' group by qdz_name union "
463   - + " select qdz_name, count(cl_zbh) as cls , 'zqj' as lx from bsth_c_s_sp_info "
464   - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' "
465   - + " and bc_type='region' and fcsj>'06:31' and fcsj<'08:00' group by qdz_name union "
466   - + " select qdz_name, count(cl_zbh) as cls , 'wqj' as lx from bsth_c_s_sp_info "
467   - + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"' "
468   - + " and bc_type='region' and fcsj>'16:01' and fcsj<'18:00'group by qdz_name";
  457 +
  458 +
  459 +
  460 + String sqlZd=" select t.*,x.station_name as qdz_name from ("
  461 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'zqc' as lx "
  462 + + " from bsth_c_s_ttinfo_detail where "
  463 + + " bc_type='normal' and ttinfo ='"+ttinfo+"' "
  464 + + " and fcsj>'06:31' and fcsj<'08:00' group by qdz,lp) t1"
  465 + + " group by qdz "
  466 + + " union "
  467 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'wqc' as lx "
  468 + + " from bsth_c_s_ttinfo_detail where "
  469 + + " bc_type='normal' and ttinfo ='"+ttinfo+"' "
  470 + + " and fcsj>'16:01' and fcsj<'18:00' group by qdz,lp) t2"
  471 + + " group by qdz "
  472 + + " union "
  473 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'zqj' as lx "
  474 + + " from bsth_c_s_ttinfo_detail where "
  475 + + " bc_type='region' and ttinfo ='"+ttinfo+"' "
  476 + + " and fcsj>'06:31' and fcsj<'08:00' group by qdz,lp) t3"
  477 + + " group by qdz "
  478 + + " union "
  479 + + " select qdz,count(lp) as cls,lx from ( select qdz,lp, 'wqj' as lx "
  480 + + " from bsth_c_s_ttinfo_detail where "
  481 + + " bc_type='region' and ttinfo ='"+ttinfo+"' "
  482 + + " and fcsj>'16:01' and fcsj<'18:00' group by qdz,lp) t4"
  483 + + " group by qdz ) t left join bsth_c_station x on t.qdz=x.id";
469 484  
470 485 List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd,
471 486 new RowMapper<Map<String, Object>>(){
... ... @@ -526,55 +541,238 @@ public class ReportServiceImpl implements ReportService{
526 541 }
527 542 return list;
528 543 }
  544 +
529 545 @Override
530   - public List<Map<String, Object>> tbodyTime5(String line, String date) {
  546 + public List<Map<String, Object>> tbodyTime4(String line, String ttinfo) {
  547 + List<Map<String, Object>> list =new ArrayList<>();
531 548 // TODO Auto-generated method stub
532   - String sql="select min(fcsj) as fcsj,'lx0' as lx from bsth_c_s_sp_info where "
533   - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'"
534   - + " and bc_type='out' and xl_dir=0 union "
535   - + " select min(fcsj) as fcsj,'lx1' as lx from bsth_c_s_sp_info where "
536   - + " DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'"
537   - + " and bc_type='out' and xl_dir=1";
538   - List<Map<String, Object>> lists= jdbcTemplate.query(sql,
539   - new RowMapper<Map<String, Object>>(){
  549 + //最早营运时间 区分夜宵线
  550 + String sqlMinYysj="select start_opt from bsth_c_line_config where line = '"+BasicData.lineId2CodeMap.inverse().get(line) +"'";
  551 + String minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  552 +
  553 + //查询全程
  554 + String sqlqc="select t.*,x.station_name as qdz_name from ( "
  555 + + "(SELECT fcsj,qdz,2 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
  556 + + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj <='"+minfcsj+"' ) "
  557 + + " union "
  558 + + " (SELECT fcsj,qdz,1 as xh,xl_dir FROM bsth_c_s_ttinfo_detail "
  559 + + " where ttinfo ='"+ttinfo+"' and bc_type='normal' and fcsj > '"+minfcsj+"') "
  560 + + "order by xl_dir,xh,fcsj ) t left join bsth_c_station x on t.qdz=x.id";
  561 + List<Map<String, String>> qclist= jdbcTemplate.query(sqlqc,
  562 + new RowMapper<Map<String, String>>(){
540 563 @Override
541   - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
542   - Map<String, Object> m=new HashMap<String,Object>();
543   - m.put("lx", rs.getString("lx"));
  564 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  565 + Map<String, String> m=new HashMap<String,String>();
  566 + m.put("qdz_name", rs.getString("qdz_name"));
544 567 m.put("fcsj", rs.getString("fcsj"));
  568 + m.put("xl", rs.getString("xl_dir"));
545 569 return m;
546 570 }
  571 +
547 572 });
  573 +
  574 + Map<String, Object> qcMap=new HashMap<String,Object>();
  575 + int num=0;
  576 + String sxfcsj="";
  577 + String xxfcsj="";
  578 + String sxzd="";
  579 + String xxzd="";
  580 + for (int i = 0; i < qclist.size(); i++) {
  581 + Map<String, String> map=qclist.get(i);
  582 + if(map.get("xl").equals("0")){
  583 + if(sxzd.equals("")){
  584 + sxzd=map.get("qdz_name").toString();
  585 + qcMap.put("sxzm", sxzd);
  586 + sxfcsj +=map.get("fcsj").toString()+"-";
  587 + }
  588 + if(!(qclist.get(i+1).get("xl").equals("0"))){
  589 + sxfcsj +=map.get("fcsj").toString();
  590 + qcMap.put("sxsj",sxfcsj);
  591 + qcMap.put("sxbc", i+1);
  592 + num=i+1;
  593 + }
  594 + }
  595 + if(map.get("xl").equals("1")){
  596 + if(xxzd.equals("")){
  597 + xxzd=map.get("qdz_name").toString();
  598 + xxfcsj+=map.get("fcsj").toString()+"-";
  599 + qcMap.put("xxzm", xxzd);
  600 + }
  601 + }
  602 + }
  603 + xxfcsj +=qclist.get(qclist.size()-1).get("fcsj").toString();
  604 + qcMap.put("xxsj", xxfcsj);
  605 + qcMap.put("xxbc", qclist.size()-num);
  606 + list.add(qcMap);
548 607  
549   - String sqlList="select * from bsth_c_s_sp_info where "
550   - + "DATE_FORMAT(schedule_date,'%Y-%m-%d') ='"+date+"' and xl_bm='"+line+"'"
551   - + " and bc_type='normal' order by fcsj";
552   - List<SchedulePlanInfo> list= jdbcTemplate.query(sqlList,
553   - new RowMapper<SchedulePlanInfo>(){
  608 +
  609 + //查询区间
  610 + String sqlqj="select t.*,x.station_name as qdz_name from ( "
  611 + + "(SELECT fcsj,qdz,'1' as gf,xl_dir FROM bsth_c_s_ttinfo_detail "
  612 + + "where ttinfo ='"+ttinfo+"' and bc_type='region' and fcsj >='06:31'"
  613 + + "and fcsj <'08:30')"
  614 + + " union ( SELECT fcsj,qdz,'2' as gf,xl_dir FROM bsth_c_s_ttinfo_detail "
  615 + + "where ttinfo ='"+ttinfo+"' and bc_type='region' "
  616 + + "and fcsj > '16:01' and fcsj < '18:00') order by xl_dir,gf,fcsj ) t "
  617 + + "left join bsth_c_station x on t.qdz=x.id";
  618 +
  619 + List<Map<String, String>> qjlist= jdbcTemplate.query(sqlqj,
  620 + new RowMapper<Map<String, String>>(){
554 621 @Override
555   - public SchedulePlanInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
556   - SchedulePlanInfo m=new SchedulePlanInfo();
557   - m.setBcsj(rs.getInt("bcsj"));
558   - m.setXlDir(rs.getString("xl_dir"));
559   - m.setFcsj(rs.getString("fcsj"));
  622 + public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {
  623 + Map<String, String> m=new HashMap<String,String>();
  624 + m.put("qdz_name", rs.getString("qdz_name"));
  625 + m.put("fcsj", rs.getString("fcsj"));
  626 + m.put("xl", rs.getString("xl_dir"));
  627 + m.put("gf", rs.getString("gf"));
560 628 return m;
561 629 }
562 630 });
563   - //上下行最早发车时间 (用于与夜班线 跨零点的班次进行比较)
564   - String lx0="";
565   - String lx1="";
566   - for (int x = 0; x < lists.size(); x++) {
567   - if(lists.get(x).get("lx").equals("lx0")){
568   - lx0=lists.get(x).get("fcsj")==null?"0:0":lists.get(x).get("fcsj").toString();
  631 +
  632 + Map<String, Object> qjzMap=new HashMap<String,Object>();
  633 + Map<String, Object> qjwMap=new HashMap<String,Object>();
  634 + int numqj=0;
  635 + String sxfcsjqj="";
  636 + String xxfcsjqj="";
  637 + String sxzdqj="";
  638 + String xxzdqj="";
  639 + for(int i=0;i<qjlist.size();i++){
  640 + Map<String, String> map=qjlist.get(i);
  641 + if(map.get("xl").toString().equals("0")){
  642 + if(map.get("gf").toString().equals("1")){
  643 + if(sxzdqj.equals("")){
  644 + sxzdqj =map.get("qdz_name").toString();
  645 + qjzMap.put("sxzm", sxzdqj);
  646 + sxfcsjqj +=map.get("fcsj").toString()+"-";
  647 + }
  648 + if(i<qjlist.size()-1){
  649 + if(!(qjlist.get(i+1).get("gf").equals("1"))){
  650 + sxfcsjqj +=map.get("fcsj").toString();
  651 + qjzMap.put("sxsj",sxfcsjqj);
  652 + qjzMap.put("sxbc", i+1);
  653 + numqj=i+1;
  654 + sxzdqj ="";
  655 + sxfcsjqj="";
  656 + }
  657 + }else{
  658 + qjzMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString());
  659 + qjzMap.put("sxbc", i+1);
  660 + numqj=i+1;
  661 + sxzdqj ="";
  662 + sxfcsjqj="";
  663 + }
  664 + }
  665 + if(map.get("gf").toString().equals("2")){
  666 + if(sxzdqj.equals("")){
  667 + sxzdqj =map.get("qdz_name").toString();
  668 + qjwMap.put("sxzm", sxzdqj);
  669 + sxfcsjqj +=map.get("fcsj").toString()+"-";
  670 + }
  671 + if(i<qjlist.size()-1){
  672 + if(!(qjlist.get(i+1).get("xl").equals("0"))){
  673 + sxfcsjqj +=map.get("fcsj").toString();
  674 + qjwMap.put("sxsj",sxfcsjqj);
  675 + qjwMap.put("sxbc", i+1-numqj);
  676 + numqj=i+1;
  677 + }
  678 + }else{
  679 + qjwMap.put("sxsj",sxfcsjqj+"-"+map.get("fcsj").toString());
  680 + qjwMap.put("sxbc", i+1-numqj);
  681 + numqj=i+1;
  682 + }
  683 + }
  684 +
569 685 }else{
570   - lx1=lists.get(x).get("fcsj")==null?"0:0":lists.get(x).get("fcsj").toString();
  686 + if(map.get("gf").toString().equals("1")){
  687 + if(xxzdqj.equals("")){
  688 + xxzdqj =map.get("qdz_name").toString();
  689 + qjzMap.put("xxzm", xxzdqj);
  690 + xxfcsjqj +=map.get("fcsj").toString()+"-";
  691 + }
  692 + if(i<qjlist.size()-1){
  693 + if(!(qjlist.get(i+1).get("gf").equals("1"))){
  694 + xxfcsjqj +=map.get("fcsj").toString();
  695 + qjzMap.put("xxsj",xxfcsjqj);
  696 + qjzMap.put("xxbc", i+1-numqj);
  697 + numqj=i+1;
  698 + xxzdqj ="";
  699 + xxfcsjqj="";
  700 + }
  701 + }else{
  702 + qjzMap.put("xxsj",xxfcsjqj+"-"+map.get("fcsj").toString());
  703 + qjzMap.put("xxbc", i+1-numqj);
  704 + numqj=i+1;
  705 + xxzdqj ="";
  706 + xxfcsjqj="";
  707 + }
  708 + }
  709 + if(map.get("gf").toString().equals("2")){
  710 + if(xxzdqj.equals("")){
  711 + xxzdqj =map.get("qdz_name").toString();
  712 + qjwMap.put("xxzm", xxzdqj);
  713 + xxfcsjqj +=map.get("fcsj").toString()+"-";
  714 + }
  715 + if(i<qjlist.size()){
  716 + if(i==qjlist.size()-1){
  717 + xxfcsjqj +=map.get("fcsj").toString();
  718 + qjwMap.put("xxsj",xxfcsjqj);
  719 + qjwMap.put("xxbc", i+1-numqj);
  720 + numqj=i+1;
  721 + }
  722 + }else{
  723 + qjwMap.put("xxsj",xxfcsjqj+"-"+xxfcsjqj);
  724 + qjwMap.put("xxbc", i+1-numqj);
  725 + numqj=i+1;
  726 + }
  727 + }
  728 +
  729 +
571 730 }
572 731 }
573 732  
574   - String[] lx0sj = lx0.split(":");
575   - int sxFc=Integer.parseInt(lx0sj[0])*60+Integer.parseInt(lx0sj[1]);
576   - String[] lx1sj = lx1.split(":");
577   - int xxFc=Integer.parseInt(lx1sj[0])*60+Integer.parseInt(lx1sj[1]);
  733 + if(!qjzMap.isEmpty()){
  734 + list.add(qjzMap);
  735 + }
  736 + if(!qjwMap.isEmpty()){
  737 + list.add(qjwMap);
  738 +
  739 + }
  740 + return list;
  741 + }
  742 + @Override
  743 + public List<Map<String, Object>> tbodyTime5(String line, String ttinfo) {
  744 + // TODO Auto-generated method stub
  745 + //最早营运时间 区分夜宵线
  746 + String sqlMinYysj="select start_opt from bsth_c_line_config where line = '"+BasicData.lineId2CodeMap.inverse().get(line) +"'";
  747 + String minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  748 + String[] minSjs = minfcsj.split(":");
  749 + int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]);
  750 + //查询时间里程
  751 + String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,2 as xh FROM "
  752 + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
  753 + + " fcsj <='"+minfcsj+"' and bc_type = 'normal') "
  754 + + " union "
  755 + + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,1 as xh FROM "
  756 + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
  757 + + " fcsj >'"+minfcsj+"' and bc_type ='normal') "
  758 + + " order by xl_dir, xh,fcsj";
  759 +
  760 + Map<String, Object> map=new HashMap<String,Object>();
  761 + List<Map<String, Object>> list= jdbcTemplate.query(sqlPc,
  762 + new RowMapper<Map<String, Object>>(){
  763 + @Override
  764 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  765 + Map<String, Object> m=new HashMap<String,Object>();
  766 + m.put("fcsj", rs.getString("fcsj"));
  767 + m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc"));
  768 + m.put("bcsj", rs.getString("bcsj"));
  769 + m.put("bcType", rs.getString("bc_type"));
  770 + m.put("lp", rs.getString("lp"));
  771 + m.put("dir", rs.getString("xl_dir"));
  772 + return m;
  773 + }
  774 + });
  775 +
578 776 //班次
579 777 int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60;
580 778  
... ... @@ -587,17 +785,17 @@ public class ReportServiceImpl implements ReportService{
587 785 //车距 (发车时间的间距) i--MIN a--MAX
588 786 int iC=999,aC=-1,iZg=999,aZg=-1,iZw=999,aZw=-1,iWg=999,aWg=-1,iJcZ=999,aJcZ=-1,iJcW=999,aJcW=-1;
589 787 int iC1=999,aC1=-1,iZg1=999,aZg1=-1,iZw1=999,aZw1=-1,iWg1=999,aWg1=-1,iJc1Z=999,aJc1Z=-1,iJc1W=999,aJc1W=-1;
590   -// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  788 +
591 789 for(int i=0;i<list.size();i++){
592   - SchedulePlanInfo t=list.get(i);
593   - String xlDir=t.getXlDir();
594   - int bcsj=t.getBcsj();
595   - String fcsj=t.getFcsj();
  790 + Map<String, Object> ttMap=list.get(i);
  791 + String xlDir=ttMap.get("dir").toString();
  792 + int bcsj=Integer.parseInt(ttMap.get("bcsj").toString());
  793 + String fcsj=ttMap.get("fcsj").toString();
596 794 String[] fcsjs=fcsj.split(":");
597 795 int fcsjNum=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]);
598 796  
599 797 if(xlDir.equals("0")){
600   - if(fcsjNum>=sxFc && fcsjNum<sj_0){
  798 + if(fcsjNum>=minSj && fcsjNum<sj_0){
601 799 ccsj0 +=bcsj;
602 800 if(aC<0){
603 801 cfc0 =fcsjNum;
... ... @@ -672,7 +870,7 @@ public class ReportServiceImpl implements ReportService{
672 870 }
673 871 jcfc0W=fcsjNum;
674 872 }
675   - }else if(fcsjNum<sxFc){
  873 + }else if(fcsjNum<minSj){
676 874 jcsj0 +=bcsj;
677 875 if(aJcZ<0){
678 876 jcfc0Z=fcsjNum;
... ... @@ -690,7 +888,7 @@ public class ReportServiceImpl implements ReportService{
690 888  
691 889  
692 890 }else{
693   - if(fcsjNum>=xxFc && fcsjNum<sj_0){
  891 + if(fcsjNum>=minSj && fcsjNum<sj_0){
694 892 ccsj1 +=bcsj;
695 893 if(aC1<0){
696 894 cfc1=fcsjNum;
... ... @@ -762,7 +960,7 @@ public class ReportServiceImpl implements ReportService{
762 960  
763 961 jcfc1W=fcsjNum;
764 962 }
765   - }else if(fcsjNum<xxFc){
  963 + }else if(fcsjNum<minSj){
766 964 jcsj1 +=bcsj;
767 965 if(aJc1Z<0){
768 966 jcfc1Z=fcsjNum;
... ... @@ -860,4 +1058,5 @@ public class ReportServiceImpl implements ReportService{
860 1058 }
861 1059 return list;
862 1060 }
  1061 +
863 1062 }
... ...
src/main/resources/static/pages/excep/boundList.html
... ... @@ -82,7 +82,9 @@
82 82 <option value="-1">无效</option>
83 83 </select>
84 84 </td>
85   - <td></td>
  85 + <td>
  86 + <input class="form-control" type="date" name="date" />
  87 + </td>
86 88 <td>
87 89 <button class="btn btn-sm green btn-outline filter-submit margin-bottom" >
88 90 <i class="fa fa-search"></i> 搜索</button>
... ... @@ -237,8 +239,20 @@ $(function(){
237 239 initPagination = false;
238 240 return;
239 241 }
  242 + var cells = $('tr.filter')[0].cells
  243 + ,params = {}
  244 + ,name;
  245 + $.each(cells, function(i, cell){
  246 + var items = $('input,select', cell);
  247 + for(var j = 0, item; item = items[j++];){
  248 + name = $(item).attr('name');
  249 + if(name){
  250 + params[name] = $(item).val();
  251 + }
  252 + }
  253 + });
240 254 page = num - 1;
241   - jsDoQuery(null, false);
  255 + jsDoQuery(params, false);
242 256 }
243 257 });
244 258 }
... ...
src/main/resources/static/pages/excep/offlineList.html
... ... @@ -82,7 +82,9 @@
82 82 <option value="-1">无效</option>
83 83 </select>
84 84 </td>
85   - <td></td>
  85 + <td>
  86 + <input class="form-control" type="date" name="date" />
  87 + </td>
86 88 <td>
87 89 <button class="btn btn-sm green btn-outline filter-submit margin-bottom" >
88 90 <i class="fa fa-search"></i> 搜索</button>
... ... @@ -242,7 +244,20 @@ $(function(){
242 244  
243 245  
244 246 page = num - 1;
245   - jsDoQuery(null, false);
  247 +
  248 + var cells = $('tr.filter')[0].cells
  249 + ,params = {}
  250 + ,name;
  251 + $.each(cells, function(i, cell){
  252 + var items = $('input,select', cell);
  253 + for(var j = 0, item; item = items[j++];){
  254 + name = $(item).attr('name');
  255 + if(name){
  256 + params[name] = $(item).val();
  257 + }
  258 + }
  259 + });
  260 + jsDoQuery(params, false);
246 261 }
247 262 });
248 263 }
... ...
src/main/resources/static/pages/excep/speedingList.html
... ... @@ -72,6 +72,7 @@
72 72 <input type="text" class="form-control form-filter input-sm" name="nbbm">
73 73 </td>
74 74 <td>
  75 + <input class="form-control" type="date" name="date" />
75 76 </td>
76 77 <td></td>
77 78 <td>
... ... @@ -238,7 +239,19 @@ $(function(){
238 239 return;
239 240 }
240 241 page = num - 1;
241   - jsDoQuery(null, false);
  242 + var cells = $('tr.filter')[0].cells
  243 + ,params = {}
  244 + ,name;
  245 + $.each(cells, function(i, cell){
  246 + var items = $('input,select', cell);
  247 + for(var j = 0, item; item = items[j++];){
  248 + name = $(item).attr('name');
  249 + if(name){
  250 + params[name] = $(item).val();
  251 + }
  252 + }
  253 + });
  254 + jsDoQuery(params, false);
242 255 }
243 256 });
244 257 }
... ...
src/main/resources/static/pages/forms/statement/scheduleDailyQp.html
... ... @@ -61,20 +61,20 @@
61 61 <th colspan="3" style="text-align:center;vertical-align:middle;">驾驶员</th>
62 62 <th colspan="3" style="text-align:center;vertical-align:middle;">售票员</th>
63 63 <th rowspan="3" style="text-align:center;vertical-align:middle;">路牌</th>
64   - <th rowspan="3" style="text-align:center;vertical-align:middle;">记录项目</th>
65   - <th colspan="3" style="text-align:center;vertical-align:middle;">1</th>
66   - <th colspan="3" style="text-align:center;vertical-align:middle;">2</th>
67   - <th colspan="3" style="text-align:center;vertical-align:middle;">3</th>
68   - <th colspan="3" style="text-align:center;vertical-align:middle;">4</th>
69   - <th colspan="3" style="text-align:center;vertical-align:middle;">5</th>
70   - <th colspan="3" style="text-align:center;vertical-align:middle;">6</th>
71   - <th colspan="3" style="text-align:center;vertical-align:middle;">7</th>
72   - <th colspan="3" style="text-align:center;vertical-align:middle;">8</th>
73   - <th colspan="3" style="text-align:center;vertical-align:middle;">9</th>
74   - <th colspan="3" style="text-align:center;vertical-align:middle;">10</th>
75   - <th colspan="3" style="text-align:center;vertical-align:middle;">11</th>
76   - <th colspan="3" style="text-align:center;vertical-align:middle;">12</th>
77   - <th colspan="3" style="text-align:center;vertical-align:middle;">13</th>
  64 + <th rowspan="4" style="text-align:center;vertical-align:middle;">记录项目</th>
  65 + <th colspan="4" style="text-align:center;vertical-align:middle;">1</th>
  66 + <th colspan="4" style="text-align:center;vertical-align:middle;">2</th>
  67 + <th colspan="4" style="text-align:center;vertical-align:middle;">3</th>
  68 + <th colspan="4" style="text-align:center;vertical-align:middle;">4</th>
  69 + <th colspan="4" style="text-align:center;vertical-align:middle;">5</th>
  70 + <th colspan="4" style="text-align:center;vertical-align:middle;">6</th>
  71 + <th colspan="4" style="text-align:center;vertical-align:middle;">7</th>
  72 + <th colspan="4" style="text-align:center;vertical-align:middle;">8</th>
  73 + <th colspan="4" style="text-align:center;vertical-align:middle;">9</th>
  74 + <th colspan="4" style="text-align:center;vertical-align:middle;">10</th>
  75 + <th colspan="4" style="text-align:center;vertical-align:middle;">11</th>
  76 + <th colspan="4" style="text-align:center;vertical-align:middle;">12</th>
  77 + <th colspan="4" style="text-align:center;vertical-align:middle;">13</th>
78 78  
79 79 </tr>
80 80 <tr>
... ... @@ -86,42 +86,55 @@
86 86 <th rowspan="2">到达</th>
87 87 <th rowspan="2">早/迟</th>
88 88 <th rowspan="2">开出</th>
  89 + <th rowspan="2">备注</th>
89 90 <th rowspan="2">到达</th>
90 91 <th rowspan="2">早/迟</th>
91 92 <th rowspan="2">开出</th>
  93 + <th rowspan="2">备注</th>
92 94 <th rowspan="2">到达</th>
93 95 <th rowspan="2">早/迟</th>
94 96 <th rowspan="2">开出</th>
  97 + <th rowspan="2">备注</th>
95 98 <th rowspan="2">到达</th>
96 99 <th rowspan="2">早/迟</th>
97 100 <th rowspan="2">开出</th>
  101 + <th rowspan="2">备注</th>
98 102 <th rowspan="2">到达</th>
99 103 <th rowspan="2">早/迟</th>
100 104 <th rowspan="2">开出</th>
  105 + <th rowspan="2">备注</th>
101 106 <th rowspan="2">到达</th>
102 107 <th rowspan="2">早/迟</th>
103 108 <th rowspan="2">开出</th>
  109 + <th rowspan="2">备注</th>
104 110 <th rowspan="2">到达</th>
105 111 <th rowspan="2">早/迟</th>
106 112 <th rowspan="2">开出</th>
  113 + <th rowspan="2">备注</th>
107 114 <th rowspan="2">到达</th>
108 115 <th rowspan="2">早/迟</th>
109 116 <th rowspan="2">开出</th>
  117 + <th rowspan="2">备注</th>
110 118 <th rowspan="2">到达</th>
111 119 <th rowspan="2">早/迟</th>
112 120 <th rowspan="2">开出</th>
  121 + <th rowspan="2">备注</th>
113 122 <th rowspan="2">到达</th>
114 123 <th rowspan="2">早/迟</th>
115 124 <th rowspan="2">开出</th>
  125 + <th rowspan="2">备注</th>
116 126 <th rowspan="2">到达</th>
117 127 <th rowspan="2">早/迟</th>
118 128 <th rowspan="2">开出</th>
  129 + <th rowspan="2">备注</th>
119 130 <th rowspan="2">到达</th>
120 131 <th rowspan="2">早/迟</th>
121 132 <th rowspan="2">开出</th>
  133 + <th rowspan="2">备注</th>
122 134 <th rowspan="2">到达</th>
123 135 <th rowspan="2">早/迟</th>
124 136 <th rowspan="2">开出</th>
  137 + <th rowspan="2">备注</th>
125 138 </tr>
126 139 <tr>
127 140 <th>出场</th>
... ... @@ -134,17 +147,80 @@
134 147 </thead>
135 148 <tbody>
136 149 <tr >
137   - <td></td>
  150 + <td>1</td>
138 151 <td>
  152 + YT-CD001
139 153 </td>
140   - <td></td>
141   - <td></td>
142   - <td></td>
143   - <td colspan="46">
144   - <div>
145   -
146   - </div>
  154 + <td>
  155 +
  156 + </td>
  157 + <td>
  158 + 1
  159 + </td>
  160 + <td>
  161 + 00001
  162 + </td>
  163 + <td >
  164 + 04:30
147 165 </td>
  166 + <td></td>
  167 + <td></td>
  168 + <td></td>
  169 + <td></td>
  170 + <td>1</td>
  171 + <td></td>
  172 + <td>06:50</td>
  173 + <td>1</td>
  174 + <td>06:00</td>
  175 + <td></td>
  176 + <td>08:02</td>
  177 + <td>-2</td>
  178 + <td>07:10</td>
  179 + <td></td>
  180 + <td></td>
  181 + <td></td>
  182 + <td></td>
  183 + <td></td>
  184 + <td></td>
  185 + <td></td>
  186 + <td></td>
  187 + <td></td>
  188 + <td></td>
  189 + <td></td>
  190 + <td></td>
  191 + <td></td>
  192 + <td></td>
  193 + <td></td>
  194 + <td></td>
  195 + <td></td>
  196 + <td></td>
  197 + <td></td>
  198 + <td></td>
  199 + <td></td>
  200 + <td></td>
  201 + <td></td>
  202 + <td></td>
  203 + <td></td>
  204 + <td></td>
  205 + <td></td>
  206 + <td></td>
  207 + <td></td>
  208 + <td></td>
  209 + <td></td>
  210 + <td></td>
  211 + <td></td>
  212 + <td></td>
  213 + <td></td>
  214 + <td></td>
  215 + <td></td>
  216 + <td></td>
  217 + <td></td>
  218 + <td></td>
  219 + <td></td>
  220 + <td></td>
  221 + <td></td>
  222 + <td></td>
  223 + <td></td>
148 224 </tr>
149 225  
150 226 </tbody>
... ...
src/main/resources/static/pages/report/inoutstation.html
... ... @@ -294,17 +294,18 @@
294 294 var id=params[0].split("\\")[0];
295 295 var fcsj = $('.in_carpark_fcsj[data-id='+id+']', '#forms').html();
296 296 var ddsj= $('.in_carpark_zdsj[data-id='+id+']', '#forms').html();
297   -
298   - $post('/report/queryListZdxx',{clzbh:nbbm,date:rq,line:line,fcsj:fcsj,ddsj:ddsj},function(result){
299   - var xlmc="线路: "+$("#select2-line-container").html();
300   - var clmc="车辆: "+nbbm;
301   - var rqmc="日期: "+rq;
302   - var bcmc="班次: "+fcsj+"-"+ddsj;
303   - $("#dlzmx").html("到离站详细 "+xlmc+" "+clmc+" "+rqmc+" "+bcmc);
304   - var ludan_ll_1 = template('ludan_ll_1',{list:result});
305   - // 把渲染好的模版html文本追加到表格中
306   - $('#forms1 .ludan_ll_1').html(ludan_ll_1);
307   - });
  297 + if(!(typeof(fcsj)=='undefined'|| typeof(ddsj)=='undefined')){
  298 + $post('/report/queryListZdxx',{clzbh:nbbm,date:rq,line:line,fcsj:fcsj,ddsj:ddsj},function(result){
  299 + var xlmc="线路: "+$("#select2-line-container").html();
  300 + var clmc="车辆: "+nbbm;
  301 + var rqmc="日期: "+rq;
  302 + var bcmc="班次: "+fcsj+"-"+ddsj;
  303 + $("#dlzmx").html("到离站详细 "+xlmc+" "+clmc+" "+rqmc+" "+bcmc);
  304 + var ludan_ll_1 = template('ludan_ll_1',{list:result});
  305 + // 把渲染好的模版html文本追加到表格中
  306 + $('#forms1 .ludan_ll_1').html(ludan_ll_1);
  307 + });
  308 + }
308 309 })
309 310  
310 311 $("#query2").click(function(){
... ...
src/main/resources/static/pages/report/timetable/timetable.html
... ... @@ -141,21 +141,21 @@
141 141 <div class="portlet-body">
142 142 <div class="row">
143 143 <div class="col-md-6" >
144   - <table class="table table-bordered table-checkable">
  144 + <table class="table table-bordered table-checkable" id="formsTime4">
145 145 <tr>
146 146 <td colspan="6">调度形式</td>
147 147 </tr>
148 148 <tr>
149   - <td colspan="3" align="center">上行向()站</td>
150   - <td colspan="3" align="center">下行向()站</td>
  149 + <td colspan="3" align="center">上行向(<span id="skb_sxzd"></span>)站</td>
  150 + <td colspan="3" align="center">下行向(<span id="skb_xxzd"></span>)站</td>
151 151 </tr>
152 152 <tr>
153   - <td>起讫站</td>
154   - <td>起讫时间</td>
155   - <td>班次</td>
156   - <td>起讫站</td>
157   - <td>起讫时间</td>
158   - <td>班次</td>
  153 + <td width="22%">起讫站</td>
  154 + <td width="20%">起讫时间</td>
  155 + <td width="8%">班次</td>
  156 + <td width="22%">起讫站</td>
  157 + <td width="20%">起讫时间</td>
  158 + <td width="8%">班次</td>
159 159 </tr>
160 160 <tbody class="tbody_time_4">
161 161  
... ... @@ -283,26 +283,25 @@
283 283 $.get('/report/tbodyTime2',{line:line,ttinfo:ttinfo},function(result){
284 284 var tbodyTime2 = template('tbodyTime2',{map:result});
285 285 $('#formsTime2 .tbody_time_2').html(tbodyTime2);
286   - });/*
  286 + });
287 287 $.get('/report/tbodyTime3',{line:line,ttinfo:ttinfo},function(result){
288   -
289 288 var tbodyTime3 = template('tbodyTime3',{list:result});
290 289 $('#formsTime3 .tbody_time_3').html(tbodyTime3);
291 290 var divTime3 = window.document.getElementById('formsTime3');
292 291 var divTime2 = window.document.getElementById('formsTime2');
293   - console.log(divTime3.offsetHeight);
294 292 divTime2.style.height=divTime3.offsetHeight+"px";
295   - }); */
  293 + });
296 294  
297   - /*
298   - $.get('/report/tbodyTime4',{line:line,date:date},function(result){
299   - var scheduleDaily_3 = template('scheduleDaily_3',{list:result});
300   - $('#forms .scheduleDaily_3').html(scheduleDaily_3);
301   - });*/
302   - /* $.get('/report/tbodyTime5',{line:line,ttinfo:ttinfo},function(result){
  295 + $.get('/report/tbodyTime4',{line:line,ttinfo:ttinfo},function(result){
  296 + $("#skb_sxzd").html(result[0].sxzm);
  297 + $("#skb_xxzd").html(result[0].xxzm);
  298 + var tbodyTime4 = template('tbodyTime4',{list:result});
  299 + $('#formsTime4 .tbody_time_4').html(tbodyTime4);
  300 + });
  301 + $.get('/report/tbodyTime5',{line:line,ttinfo:ttinfo},function(result){
303 302 var tbodyTime5 = template('tbodyTime5',{list:result});
304 303 $('#formsTime5 .tbody_time_5').html(tbodyTime5);
305   - }); */
  304 + });
306 305 }
307 306  
308 307  
... ... @@ -352,6 +351,27 @@
352 351 </script>
353 352  
354 353  
  354 +
  355 +
  356 +<script type="text/html" id="tbodyTime4">
  357 +{{each list as result i}}
  358 +
  359 + <tr>
  360 + <td align="center">{{result.sxzm}}</td>
  361 + <td align="center">{{result.sxsj}}</td>
  362 + <td align="center">{{result.sxbc}}</td>
  363 + <td align="center">{{result.xxzm}}</td>
  364 + <td align="center">{{result.xxsj}}</td>
  365 + <td align="center">{{result.xxbc}}</td>
  366 + </tr>
  367 +{{/each}}
  368 +{{if list.length == 0}}
  369 + <tr>
  370 + <td colspan="5"><h6 class="muted">没有找到相关数据</h6></td>
  371 + </tr>
  372 + {{/if}}
  373 +</script>
  374 +
355 375 <script type="text/html" id="tbodyTime5">
356 376 {{each list as result i}}
357 377 <tr>
... ...