Commit e446403e015c4eb2b4799b8d4e8720853d2bbb47
Merge branch 'minhang' of http://192.168.168.201:8888/panzhaov5/bsth_control into minhang
Showing
42 changed files
with
2198 additions
and
1705 deletions
src/main/java/com/bsth/controller/report/ReportController.java
| @@ -64,6 +64,11 @@ public class ReportController { | @@ -64,6 +64,11 @@ public class ReportController { | ||
| 64 | return service.tbodyTime3(line, ttinfo); | 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 | @RequestMapping(value = "/tbodyTime5", method = RequestMethod.GET) | 72 | @RequestMapping(value = "/tbodyTime5", method = RequestMethod.GET) |
| 68 | public List<Map<String, Object>> tbodyTime5(@RequestParam String line,@RequestParam String ttinfo) { | 73 | public List<Map<String, Object>> tbodyTime5(@RequestParam String line,@RequestParam String ttinfo) { |
| 69 | return service.tbodyTime5(line, ttinfo); | 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 | \ No newline at end of file | 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 | \ No newline at end of file | 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 | \ No newline at end of file | 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,23 +46,33 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 46 | Object line=map.get("line"); | 46 | Object line=map.get("line"); |
| 47 | Object nbbm=map.get("nbbm"); | 47 | Object nbbm=map.get("nbbm"); |
| 48 | Object updown=map.get("updown"); | 48 | Object updown=map.get("updown"); |
| 49 | - | 49 | + Object date=map.get("date"); |
| 50 | 50 | ||
| 51 | if(line!=null){ | 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 | if(nbbm!=null){ | 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 | if(updown!=null){ | 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 | sql +=" order by id limit ?,?"; | 76 | sql +=" order by id limit ?,?"; |
| 67 | 77 | ||
| 68 | try { | 78 | try { |
| @@ -118,19 +128,32 @@ public class OfflineServiceImpl implements OfflineService { | @@ -118,19 +128,32 @@ public class OfflineServiceImpl implements OfflineService { | ||
| 118 | Object nbbm=map.get("nbbm"); | 128 | Object nbbm=map.get("nbbm"); |
| 119 | Object updown=map.get("updown"); | 129 | Object updown=map.get("updown"); |
| 120 | 130 | ||
| 131 | + Object date=map.get("date"); | ||
| 132 | + | ||
| 121 | if(line!=null){ | 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 | if(nbbm!=null){ | 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 | if(updown!=null){ | 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 | Connection conn = null; | 159 | Connection conn = null; |
src/main/java/com/bsth/service/excep/impl/OutboundServiceImpl.java
| @@ -36,23 +36,33 @@ public class OutboundServiceImpl implements OutboundService{ | @@ -36,23 +36,33 @@ public class OutboundServiceImpl implements OutboundService{ | ||
| 36 | Object line=map.get("line"); | 36 | Object line=map.get("line"); |
| 37 | Object nbbm=map.get("nbbm"); | 37 | Object nbbm=map.get("nbbm"); |
| 38 | Object updown=map.get("updown"); | 38 | Object updown=map.get("updown"); |
| 39 | + Object date=map.get("date"); | ||
| 39 | 40 | ||
| 40 | - | ||
| 41 | if(line!=null){ | 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 | if(nbbm!=null){ | 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 | if(updown!=null){ | 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 | sql +=" order by id limit ?,?"; | 66 | sql +=" order by id limit ?,?"; |
| 57 | 67 | ||
| 58 | 68 | ||
| @@ -102,20 +112,32 @@ public class OutboundServiceImpl implements OutboundService{ | @@ -102,20 +112,32 @@ public class OutboundServiceImpl implements OutboundService{ | ||
| 102 | Object line=map.get("line"); | 112 | Object line=map.get("line"); |
| 103 | Object nbbm=map.get("nbbm"); | 113 | Object nbbm=map.get("nbbm"); |
| 104 | Object updown=map.get("updown"); | 114 | Object updown=map.get("updown"); |
| 105 | - | 115 | + Object date=map.get("date"); |
| 106 | if(line!=null){ | 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 | if(nbbm!=null){ | 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 | if(updown!=null){ | 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 | Connection conn = null; | 142 | Connection conn = null; |
| 121 | PreparedStatement ps = null; | 143 | PreparedStatement ps = null; |
| @@ -214,7 +236,7 @@ public class OutboundServiceImpl implements OutboundService{ | @@ -214,7 +236,7 @@ public class OutboundServiceImpl implements OutboundService{ | ||
| 214 | times=sdf.format(new Date()); | 236 | times=sdf.format(new Date()); |
| 215 | } | 237 | } |
| 216 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 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 | String times2=times+" 23:59:59"; | 240 | String times2=times+" 23:59:59"; |
| 219 | 241 | ||
| 220 | Connection conn = null; | 242 | Connection conn = null; |
src/main/java/com/bsth/service/excep/impl/SpeedingServiceImpl.java
| @@ -38,22 +38,34 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -38,22 +38,34 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 38 | Object line=map.get("line"); | 38 | Object line=map.get("line"); |
| 39 | Object nbbm=map.get("nbbm"); | 39 | Object nbbm=map.get("nbbm"); |
| 40 | Object updown=map.get("updown"); | 40 | Object updown=map.get("updown"); |
| 41 | - | 41 | + Object date=map.get("date"); |
| 42 | 42 | ||
| 43 | if(line!=null){ | 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 | if(nbbm!=null){ | 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 | if(updown!=null){ | 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 | sql +=" order by id limit ?,?"; | 70 | sql +=" order by id limit ?,?"; |
| 59 | 71 | ||
| @@ -103,19 +115,32 @@ public class SpeedingServiceImpl implements SpeedingService { | @@ -103,19 +115,32 @@ public class SpeedingServiceImpl implements SpeedingService { | ||
| 103 | Object nbbm=map.get("nbbm"); | 115 | Object nbbm=map.get("nbbm"); |
| 104 | Object updown=map.get("updown"); | 116 | Object updown=map.get("updown"); |
| 105 | 117 | ||
| 118 | + Object date=map.get("date"); | ||
| 119 | + | ||
| 106 | if(line!=null){ | 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 | if(nbbm!=null){ | 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 | if(updown!=null){ | 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 | Connection conn = null; | 145 | Connection conn = null; |
| 121 | PreparedStatement ps = null; | 146 | PreparedStatement ps = null; |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -1212,7 +1212,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1212,7 +1212,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1212 | map.put("ljbc", ljbc); | 1212 | map.put("ljbc", ljbc); |
| 1213 | map.put("sjbc", jhbc-cjbc+ljbc); | 1213 | map.put("sjbc", jhbc-cjbc+ljbc); |
| 1214 | map.put("jcclc", jcclc); | 1214 | map.put("jcclc", jcclc); |
| 1215 | - map.put("zkslc", ksgl+jcclc); | 1215 | + map.put("zkslc", format.format(ksgl+jcclc)); |
| 1216 | return map; | 1216 | return map; |
| 1217 | } | 1217 | } |
| 1218 | 1218 | ||
| @@ -1226,7 +1226,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1226,7 +1226,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1226 | if(obj != null){ | 1226 | if(obj != null){ |
| 1227 | map = new HashMap<String,Object>(); | 1227 | map = new HashMap<String,Object>(); |
| 1228 | map.put("xlName", xlName); | 1228 | map.put("xlName", xlName); |
| 1229 | - map.put("clZbh", code); | 1229 | + map.put("clZbh", obj[3]); |
| 1230 | map.put("company", obj[0]); | 1230 | map.put("company", obj[0]); |
| 1231 | map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase()); | 1231 | map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase()); |
| 1232 | map.put("requestTime", obj[2]); | 1232 | map.put("requestTime", obj[2]); |
src/main/java/com/bsth/service/report/ReportService.java
| @@ -24,6 +24,8 @@ public interface ReportService { | @@ -24,6 +24,8 @@ public interface ReportService { | ||
| 24 | Map<String, Object> tbodyTime2(String line ,String ttinfo); | 24 | Map<String, Object> tbodyTime2(String line ,String ttinfo); |
| 25 | 25 | ||
| 26 | List<Map<String, Object>> tbodyTime3(String line ,String ttinfo); | 26 | List<Map<String, Object>> tbodyTime3(String line ,String ttinfo); |
| 27 | + | ||
| 28 | + List<Map<String, Object>> tbodyTime4(String line ,String ttinfo); | ||
| 27 | List<Map<String, Object>> tbodyTime5(String line ,String ttinfo); | 29 | List<Map<String, Object>> tbodyTime5(String line ,String ttinfo); |
| 28 | 30 | ||
| 29 | List<Map<String, Object>> getTtinfo(Map<String, Object> map); | 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,21 +451,36 @@ public class ReportServiceImpl implements ReportService{ | ||
| 451 | System.out.println(609360%60); | 451 | System.out.println(609360%60); |
| 452 | } | 452 | } |
| 453 | @Override | 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 | // TODO Auto-generated method stub | 455 | // TODO Auto-generated method stub |
| 456 | List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); | 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 | List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, | 485 | List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, |
| 471 | new RowMapper<Map<String, Object>>(){ | 486 | new RowMapper<Map<String, Object>>(){ |
| @@ -526,55 +541,238 @@ public class ReportServiceImpl implements ReportService{ | @@ -526,55 +541,238 @@ public class ReportServiceImpl implements ReportService{ | ||
| 526 | } | 541 | } |
| 527 | return list; | 542 | return list; |
| 528 | } | 543 | } |
| 544 | + | ||
| 529 | @Override | 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 | // TODO Auto-generated method stub | 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 | @Override | 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 | m.put("fcsj", rs.getString("fcsj")); | 567 | m.put("fcsj", rs.getString("fcsj")); |
| 568 | + m.put("xl", rs.getString("xl_dir")); | ||
| 545 | return m; | 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 | @Override | 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 | return m; | 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 | }else{ | 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 | int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60; | 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,17 +785,17 @@ public class ReportServiceImpl implements ReportService{ | ||
| 587 | //车距 (发车时间的间距) i--MIN a--MAX | 785 | //车距 (发车时间的间距) i--MIN a--MAX |
| 588 | 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; | 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 | 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; | 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 | for(int i=0;i<list.size();i++){ | 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 | String[] fcsjs=fcsj.split(":"); | 794 | String[] fcsjs=fcsj.split(":"); |
| 597 | int fcsjNum=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]); | 795 | int fcsjNum=Integer.parseInt(fcsjs[0])*60+Integer.parseInt(fcsjs[1]); |
| 598 | 796 | ||
| 599 | if(xlDir.equals("0")){ | 797 | if(xlDir.equals("0")){ |
| 600 | - if(fcsjNum>=sxFc && fcsjNum<sj_0){ | 798 | + if(fcsjNum>=minSj && fcsjNum<sj_0){ |
| 601 | ccsj0 +=bcsj; | 799 | ccsj0 +=bcsj; |
| 602 | if(aC<0){ | 800 | if(aC<0){ |
| 603 | cfc0 =fcsjNum; | 801 | cfc0 =fcsjNum; |
| @@ -672,7 +870,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -672,7 +870,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 672 | } | 870 | } |
| 673 | jcfc0W=fcsjNum; | 871 | jcfc0W=fcsjNum; |
| 674 | } | 872 | } |
| 675 | - }else if(fcsjNum<sxFc){ | 873 | + }else if(fcsjNum<minSj){ |
| 676 | jcsj0 +=bcsj; | 874 | jcsj0 +=bcsj; |
| 677 | if(aJcZ<0){ | 875 | if(aJcZ<0){ |
| 678 | jcfc0Z=fcsjNum; | 876 | jcfc0Z=fcsjNum; |
| @@ -690,7 +888,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -690,7 +888,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 690 | 888 | ||
| 691 | 889 | ||
| 692 | }else{ | 890 | }else{ |
| 693 | - if(fcsjNum>=xxFc && fcsjNum<sj_0){ | 891 | + if(fcsjNum>=minSj && fcsjNum<sj_0){ |
| 694 | ccsj1 +=bcsj; | 892 | ccsj1 +=bcsj; |
| 695 | if(aC1<0){ | 893 | if(aC1<0){ |
| 696 | cfc1=fcsjNum; | 894 | cfc1=fcsjNum; |
| @@ -762,7 +960,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -762,7 +960,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 762 | 960 | ||
| 763 | jcfc1W=fcsjNum; | 961 | jcfc1W=fcsjNum; |
| 764 | } | 962 | } |
| 765 | - }else if(fcsjNum<xxFc){ | 963 | + }else if(fcsjNum<minSj){ |
| 766 | jcsj1 +=bcsj; | 964 | jcsj1 +=bcsj; |
| 767 | if(aJc1Z<0){ | 965 | if(aJc1Z<0){ |
| 768 | jcfc1Z=fcsjNum; | 966 | jcfc1Z=fcsjNum; |
| @@ -860,4 +1058,5 @@ public class ReportServiceImpl implements ReportService{ | @@ -860,4 +1058,5 @@ public class ReportServiceImpl implements ReportService{ | ||
| 860 | } | 1058 | } |
| 861 | return list; | 1059 | return list; |
| 862 | } | 1060 | } |
| 1061 | + | ||
| 863 | } | 1062 | } |
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
| @@ -180,6 +180,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -180,6 +180,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 180 | 180 | ||
| 181 | 181 | ||
| 182 | } catch (Exception e) { | 182 | } catch (Exception e) { |
| 183 | + | ||
| 183 | // TODO Auto-generated catch block | 184 | // TODO Auto-generated catch block |
| 184 | e.printStackTrace(); | 185 | e.printStackTrace(); |
| 185 | } | 186 | } |
| @@ -313,6 +314,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -313,6 +314,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 313 | // TODO Auto-generated catch block | 314 | // TODO Auto-generated catch block |
| 314 | e.printStackTrace(); | 315 | e.printStackTrace(); |
| 315 | } | 316 | } |
| 317 | + String companyName = "", subCompanyName = ""; | ||
| 318 | + | ||
| 316 | for(String key : keyMap.keySet()){ | 319 | for(String key : keyMap.keySet()){ |
| 317 | Map<String, Object> tempMap = new HashMap<String, Object>(); | 320 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 318 | Map<String, List <ScheduleRealInfo>> listMap = new HashMap<String, List <ScheduleRealInfo>>(); | 321 | Map<String, List <ScheduleRealInfo>> listMap = new HashMap<String, List <ScheduleRealInfo>>(); |
| @@ -323,6 +326,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -323,6 +326,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 323 | int jhzgf = 0, sjzgf = 0, jhwgf = 0, sjwgf = 0; | 326 | int jhzgf = 0, sjzgf = 0, jhwgf = 0, sjwgf = 0; |
| 324 | for(ScheduleRealInfo schedule : keyMap.get(key)){ | 327 | for(ScheduleRealInfo schedule : keyMap.get(key)){ |
| 325 | // schedule.setFcsjAll(schedule.getFcsj()); | 328 | // schedule.setFcsjAll(schedule.getFcsj()); |
| 329 | + if(companyName.length() == 0 && schedule.getGsName() != null) | ||
| 330 | + companyName = schedule.getGsName(); | ||
| 331 | + if(subCompanyName.length() == 0 && schedule.getFgsName() != null) | ||
| 332 | + subCompanyName = schedule.getFgsName(); | ||
| 326 | 333 | ||
| 327 | //早晚高峰时段执行率 | 334 | //早晚高峰时段执行率 |
| 328 | if(schedule.getFcsjT() >= zgfBegin && schedule.getFcsjT() <= zgfEnd){ | 335 | if(schedule.getFcsjT() >= zgfBegin && schedule.getFcsjT() <= zgfEnd){ |
| @@ -424,6 +431,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -424,6 +431,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 424 | 431 | ||
| 425 | } | 432 | } |
| 426 | 433 | ||
| 434 | + tempMap.put("company", companyName); | ||
| 435 | + tempMap.put("subCompany", subCompanyName); | ||
| 427 | tempMap.put("date", date); | 436 | tempMap.put("date", date); |
| 428 | tempMap.put("line", key); | 437 | tempMap.put("line", key); |
| 429 | tempMap.put("jhbc", jhbc); | 438 | tempMap.put("jhbc", jhbc); |
| @@ -509,6 +518,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -509,6 +518,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 509 | schedule.setScheduleDateStr(rs.getString("schedule_date_Str")); | 518 | schedule.setScheduleDateStr(rs.getString("schedule_date_Str")); |
| 510 | schedule.setXlName(rs.getString("xl_name")); | 519 | schedule.setXlName(rs.getString("xl_name")); |
| 511 | schedule.setBcType(rs.getString("bc_type")); | 520 | schedule.setBcType(rs.getString("bc_type")); |
| 521 | + schedule.setGsName(rs.getString("gs_name")); | ||
| 522 | + schedule.setFgsName(rs.getString("fgs_name")); | ||
| 512 | schedule.setBcs(rs.getInt("bcs")); | 523 | schedule.setBcs(rs.getInt("bcs")); |
| 513 | schedule.setFcno(rs.getInt("fcno")); | 524 | schedule.setFcno(rs.getInt("fcno")); |
| 514 | schedule.setFcsj(rs.getString("fcsj")); | 525 | schedule.setFcsj(rs.getString("fcsj")); |
| @@ -588,6 +599,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -588,6 +599,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 588 | } | 599 | } |
| 589 | } | 600 | } |
| 590 | } | 601 | } |
| 602 | + String companyName = "", subCompanyName = ""; | ||
| 591 | for(String key : keyMap.keySet()){ | 603 | for(String key : keyMap.keySet()){ |
| 592 | Map<String, Object> tempMap = new HashMap<String, Object>(); | 604 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 593 | List<Integer> fcsj = new ArrayList<Integer>(); | 605 | List<Integer> fcsj = new ArrayList<Integer>(); |
| @@ -595,6 +607,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -595,6 +607,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 595 | int jhbc = 0; | 607 | int jhbc = 0; |
| 596 | int sjbc = 0; | 608 | int sjbc = 0; |
| 597 | for(ScheduleRealInfo schedule : keyMap.get(key)){ | 609 | for(ScheduleRealInfo schedule : keyMap.get(key)){ |
| 610 | + if(companyName.length() == 0 && schedule.getGsName() != null) | ||
| 611 | + companyName = schedule.getGsName(); | ||
| 612 | + if(subCompanyName.length() == 0 && schedule.getFgsName() != null) | ||
| 613 | + subCompanyName = schedule.getFgsName(); | ||
| 614 | + | ||
| 598 | tempMap.put("date", schedule.getScheduleDateStr()); | 615 | tempMap.put("date", schedule.getScheduleDateStr()); |
| 599 | tempMap.put("bcsj", schedule.getBcsj()); | 616 | tempMap.put("bcsj", schedule.getBcsj()); |
| 600 | if(schedule.getFcsjActual() != null){ | 617 | if(schedule.getFcsjActual() != null){ |
| @@ -654,6 +671,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -654,6 +671,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 654 | tempMap.put("zmys", "/"); | 671 | tempMap.put("zmys", "/"); |
| 655 | tempMap.put("pjys", "/"); | 672 | tempMap.put("pjys", "/"); |
| 656 | } | 673 | } |
| 674 | + tempMap.put("company", companyName); | ||
| 675 | + tempMap.put("subCompany", subCompanyName); | ||
| 657 | String[] split = key.split("/"); | 676 | String[] split = key.split("/"); |
| 658 | tempMap.put("line", split[0]); | 677 | tempMap.put("line", split[0]); |
| 659 | tempMap.put("qdz", split[1]); | 678 | tempMap.put("qdz", split[1]); |
src/main/resources/static/pages/excep/boundList.html
| @@ -82,7 +82,9 @@ | @@ -82,7 +82,9 @@ | ||
| 82 | <option value="-1">无效</option> | 82 | <option value="-1">无效</option> |
| 83 | </select> | 83 | </select> |
| 84 | </td> | 84 | </td> |
| 85 | - <td></td> | 85 | + <td> |
| 86 | + <input class="form-control" type="date" name="date" /> | ||
| 87 | + </td> | ||
| 86 | <td> | 88 | <td> |
| 87 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > | 89 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > |
| 88 | <i class="fa fa-search"></i> 搜索</button> | 90 | <i class="fa fa-search"></i> 搜索</button> |
| @@ -237,8 +239,20 @@ $(function(){ | @@ -237,8 +239,20 @@ $(function(){ | ||
| 237 | initPagination = false; | 239 | initPagination = false; |
| 238 | return; | 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 | page = num - 1; | 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,7 +82,9 @@ | ||
| 82 | <option value="-1">无效</option> | 82 | <option value="-1">无效</option> |
| 83 | </select> | 83 | </select> |
| 84 | </td> | 84 | </td> |
| 85 | - <td></td> | 85 | + <td> |
| 86 | + <input class="form-control" type="date" name="date" /> | ||
| 87 | + </td> | ||
| 86 | <td> | 88 | <td> |
| 87 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > | 89 | <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > |
| 88 | <i class="fa fa-search"></i> 搜索</button> | 90 | <i class="fa fa-search"></i> 搜索</button> |
| @@ -242,7 +244,20 @@ $(function(){ | @@ -242,7 +244,20 @@ $(function(){ | ||
| 242 | 244 | ||
| 243 | 245 | ||
| 244 | page = num - 1; | 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,6 +72,7 @@ | ||
| 72 | <input type="text" class="form-control form-filter input-sm" name="nbbm"> | 72 | <input type="text" class="form-control form-filter input-sm" name="nbbm"> |
| 73 | </td> | 73 | </td> |
| 74 | <td> | 74 | <td> |
| 75 | + <input class="form-control" type="date" name="date" /> | ||
| 75 | </td> | 76 | </td> |
| 76 | <td></td> | 77 | <td></td> |
| 77 | <td> | 78 | <td> |
| @@ -238,7 +239,19 @@ $(function(){ | @@ -238,7 +239,19 @@ $(function(){ | ||
| 238 | return; | 239 | return; |
| 239 | } | 240 | } |
| 240 | page = num - 1; | 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/mould/peoCarPlan.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/scheduleAnaly.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/workDaily.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/account.html
| @@ -133,7 +133,7 @@ | @@ -133,7 +133,7 @@ | ||
| 133 | 133 | ||
| 134 | $("#query").on("click",function(){ | 134 | $("#query").on("click",function(){ |
| 135 | var line = $("#line").val(); | 135 | var line = $("#line").val(); |
| 136 | - var xlName = $("#line").text(); | 136 | + var xlName = $("#select2-line-container").html(); |
| 137 | var date = $("#date").val(); | 137 | var date = $("#date").val(); |
| 138 | var code = $("#code").val(); | 138 | var code = $("#code").val(); |
| 139 | $(".hidden").removeClass("hidden"); | 139 | $(".hidden").removeClass("hidden"); |
src/main/resources/static/pages/forms/statement/correctForm.html
| @@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
| 49 | </div> | 49 | </div> |
| 50 | <div class="form-group"> | 50 | <div class="form-group"> |
| 51 | <input class="btn btn-default" type="button" id="query" value="筛选"/> | 51 | <input class="btn btn-default" type="button" id="query" value="筛选"/> |
| 52 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | 52 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> |
| 53 | </div> | 53 | </div> |
| 54 | </form> | 54 | </form> |
| 55 | </div> | 55 | </div> |
src/main/resources/static/pages/forms/statement/firstAndLastBus.html
| @@ -97,6 +97,7 @@ | @@ -97,6 +97,7 @@ | ||
| 97 | 97 | ||
| 98 | <script> | 98 | <script> |
| 99 | $(function(){ | 99 | $(function(){ |
| 100 | + $('#export').attr('disabled', "true"); | ||
| 100 | 101 | ||
| 101 | // 关闭左侧栏 | 102 | // 关闭左侧栏 |
| 102 | if (!$('body').hasClass('page-sidebar-closed')) | 103 | if (!$('body').hasClass('page-sidebar-closed')) |
| @@ -186,11 +187,22 @@ | @@ -186,11 +187,22 @@ | ||
| 186 | // 把渲染好的模版html文本追加到表格中 | 187 | // 把渲染好的模版html文本追加到表格中 |
| 187 | $('#forms tbody').html(tbodyHtml); | 188 | $('#forms tbody').html(tbodyHtml); |
| 188 | 189 | ||
| 190 | + if(result.length == 0) | ||
| 191 | + $("#export").attr('disabled',"true"); | ||
| 192 | + else | ||
| 193 | + $("#export").removeAttr("disabled"); | ||
| 189 | }); | 194 | }); |
| 190 | } | 195 | } |
| 191 | 196 | ||
| 192 | $("#export").on("click",function(){ | 197 | $("#export").on("click",function(){ |
| 193 | - $get('/pcpc/firstAndLastBus',{line:line,date:date,type:'export'},function(result){ | 198 | + var params = {}; |
| 199 | + params['company'] = company; | ||
| 200 | + params['subCompany'] = subCompany; | ||
| 201 | + params['line'] = line; | ||
| 202 | + params['line'] = line; | ||
| 203 | + params['date'] = date; | ||
| 204 | + params['type'] = "export"; | ||
| 205 | + $get('/pcpc/firstAndLastBus', params, function(result){ | ||
| 194 | window.open("/downloadFile/download?fileName=线路首末班"+moment(date).format("YYYYMMDD")); | 206 | window.open("/downloadFile/download?fileName=线路首末班"+moment(date).format("YYYYMMDD")); |
| 195 | }); | 207 | }); |
| 196 | }); | 208 | }); |
src/main/resources/static/pages/forms/statement/historyMessage.html
| @@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
| 41 | </div> | 41 | </div> |
| 42 | <div class="form-group"> | 42 | <div class="form-group"> |
| 43 | <input class="btn btn-default" type="button" id="query" value="筛选"/> | 43 | <input class="btn btn-default" type="button" id="query" value="筛选"/> |
| 44 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | 44 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> |
| 45 | </div> | 45 | </div> |
| 46 | </form> | 46 | </form> |
| 47 | </div> | 47 | </div> |
src/main/resources/static/pages/forms/statement/peopleCarPlan.html
| @@ -80,6 +80,7 @@ | @@ -80,6 +80,7 @@ | ||
| 80 | 80 | ||
| 81 | <script> | 81 | <script> |
| 82 | $(function(){ | 82 | $(function(){ |
| 83 | + $('#export').attr('disabled', "true"); | ||
| 83 | 84 | ||
| 84 | // 关闭左侧栏 | 85 | // 关闭左侧栏 |
| 85 | if (!$('body').hasClass('page-sidebar-closed')) | 86 | if (!$('body').hasClass('page-sidebar-closed')) |
| @@ -168,11 +169,21 @@ | @@ -168,11 +169,21 @@ | ||
| 168 | // 把渲染好的模版html文本追加到表格中 | 169 | // 把渲染好的模版html文本追加到表格中 |
| 169 | $('#forms tbody').html(tbodyHtml); | 170 | $('#forms tbody').html(tbodyHtml); |
| 170 | 171 | ||
| 172 | + if(result.length == 0) | ||
| 173 | + $("#export").attr('disabled',"true"); | ||
| 174 | + else | ||
| 175 | + $("#export").removeAttr("disabled"); | ||
| 171 | }); | 176 | }); |
| 172 | } | 177 | } |
| 173 | 178 | ||
| 174 | $("#export").on("click",function(){ | 179 | $("#export").on("click",function(){ |
| 175 | - $get('/pcpc/queryPeopleCar',{line:line,date:date,type:'export'},function(result){ | 180 | + var params = {}; |
| 181 | + params['company'] = company; | ||
| 182 | + params['subCompany'] = subCompany; | ||
| 183 | + params['line'] = line; | ||
| 184 | + params['date'] = date; | ||
| 185 | + params['type'] = "export"; | ||
| 186 | + $get('/pcpc/queryPeopleCar', params, function(result){ | ||
| 176 | window.open("/downloadFile/download?fileName=计划车辆班次人员"+moment(date).format("YYYYMMDD")); | 187 | window.open("/downloadFile/download?fileName=计划车辆班次人员"+moment(date).format("YYYYMMDD")); |
| 177 | }); | 188 | }); |
| 178 | }); | 189 | }); |
src/main/resources/static/pages/forms/statement/scheduleAnaly.html
| @@ -65,18 +65,21 @@ | @@ -65,18 +65,21 @@ | ||
| 65 | <table class="table table-bordered table-hover table-checkable" id="forms"> | 65 | <table class="table table-bordered table-hover table-checkable" id="forms"> |
| 66 | <thead> | 66 | <thead> |
| 67 | <tr class="hidden"> | 67 | <tr class="hidden"> |
| 68 | - <th width="10%">线路</th> | ||
| 69 | - <th width="10%">起点站名</th> | ||
| 70 | - <th width="8%">计发时间</th> | ||
| 71 | - <th width="8%">计划运送时间(分)</th> | ||
| 72 | - <th width="8%">计划完成次数</th> | ||
| 73 | - <th width="8%">完成次数</th> | ||
| 74 | - <th width="8%">最早发车时间</th> | ||
| 75 | - <th width="8%">最晚发车时间</th> | ||
| 76 | - <th width="8%">平均发车时间</th> | ||
| 77 | - <th width="8%">最慢运送时间(分)</th> | ||
| 78 | - <th width="8%">最快运送时间(分)</th> | ||
| 79 | - <th width="8%">平均运送时间(分)</th> | 68 | + <th style="display: none;"></th> |
| 69 | + <th width="8%">公司</th> | ||
| 70 | + <th width="8%">分公司</th> | ||
| 71 | + <th width="8%">线路</th> | ||
| 72 | + <th width="8%">起点站名</th> | ||
| 73 | + <th width="6%">计发时间</th> | ||
| 74 | + <th width="6%">计划运送时间(分)</th> | ||
| 75 | + <th width="6%">计划完成次数</th> | ||
| 76 | + <th width="6%">完成次数</th> | ||
| 77 | + <th width="6%">最早发车时间</th> | ||
| 78 | + <th width="6%">最晚发车时间</th> | ||
| 79 | + <th width="6%">平均发车时间</th> | ||
| 80 | + <th width="6%">最慢运送时间(分)</th> | ||
| 81 | + <th width="6%">最快运送时间(分)</th> | ||
| 82 | + <th width="6%">平均运送时间(分)</th> | ||
| 80 | </tr> | 83 | </tr> |
| 81 | </thead> | 84 | </thead> |
| 82 | <tbody> | 85 | <tbody> |
| @@ -95,6 +98,7 @@ | @@ -95,6 +98,7 @@ | ||
| 95 | <script> | 98 | <script> |
| 96 | $(function(){ | 99 | $(function(){ |
| 97 | var page = 0, initPagination; | 100 | var page = 0, initPagination; |
| 101 | + $('#export').attr('disabled', "true"); | ||
| 98 | 102 | ||
| 99 | // 关闭左侧栏 | 103 | // 关闭左侧栏 |
| 100 | if (!$('body').hasClass('page-sidebar-closed')) | 104 | if (!$('body').hasClass('page-sidebar-closed')) |
| @@ -200,6 +204,11 @@ | @@ -200,6 +204,11 @@ | ||
| 200 | // 把渲染好的模版html文本追加到表格中 | 204 | // 把渲染好的模版html文本追加到表格中 |
| 201 | $('#forms tbody').html(tbodyHtml); | 205 | $('#forms tbody').html(tbodyHtml); |
| 202 | 206 | ||
| 207 | + if(result.dataList.length == 0) | ||
| 208 | + $("#export").attr('disabled',"true"); | ||
| 209 | + else | ||
| 210 | + $("#export").removeAttr("disabled"); | ||
| 211 | + | ||
| 203 | if(pagination && result.dataList.length > 0){ | 212 | if(pagination && result.dataList.length > 0){ |
| 204 | //重新分页 | 213 | //重新分页 |
| 205 | initPagination = true; | 214 | initPagination = true; |
| @@ -213,7 +222,16 @@ | @@ -213,7 +222,16 @@ | ||
| 213 | } | 222 | } |
| 214 | 223 | ||
| 215 | $("#export").on("click",function(){ | 224 | $("#export").on("click",function(){ |
| 216 | - $get('/pcpc/scheduleAnaly',{page:'',line:line,startDate:startDate,endDate:endDate,model:model,type:'export'},function(result){ | 225 | + var params = {}; |
| 226 | + params['page'] = page; | ||
| 227 | + params['line'] = line; | ||
| 228 | + params['startDate'] = startDate; | ||
| 229 | + params['endDate'] = endDate; | ||
| 230 | + params['model'] = model; | ||
| 231 | + params['company'] = company; | ||
| 232 | + params['subCompany'] = subCompany; | ||
| 233 | + params['type'] = "export"; | ||
| 234 | + $get('/pcpc/scheduleAnaly', params, function(result){ | ||
| 217 | window.open("/downloadFile/download?fileName=时刻表分析"+moment(startDate).format("YYYYMMDD")+"-"+moment(endDate).format("YYYYMMDD")); | 235 | window.open("/downloadFile/download?fileName=时刻表分析"+moment(startDate).format("YYYYMMDD")+"-"+moment(endDate).format("YYYYMMDD")); |
| 218 | }); | 236 | }); |
| 219 | }); | 237 | }); |
| @@ -289,6 +307,9 @@ | @@ -289,6 +307,9 @@ | ||
| 289 | <script type="text/html" id="list_scheduleAnaly"> | 307 | <script type="text/html" id="list_scheduleAnaly"> |
| 290 | {{each list as obj i}} | 308 | {{each list as obj i}} |
| 291 | <tr> | 309 | <tr> |
| 310 | + <th style="display: none;"></th> | ||
| 311 | + <td>{{obj.company}}</td> | ||
| 312 | + <td>{{obj.subCompany}}</td> | ||
| 292 | <td>{{obj.line}}</td> | 313 | <td>{{obj.line}}</td> |
| 293 | <td>{{obj.qdz}}</td> | 314 | <td>{{obj.qdz}}</td> |
| 294 | <td>{{obj.jhfc}}</td> | 315 | <td>{{obj.jhfc}}</td> |
| @@ -305,7 +326,7 @@ | @@ -305,7 +326,7 @@ | ||
| 305 | {{/each}} | 326 | {{/each}} |
| 306 | {{if list.length == 0}} | 327 | {{if list.length == 0}} |
| 307 | <tr> | 328 | <tr> |
| 308 | - <td colspan="12"><h6 class="muted">没有找到相关数据</h6></td> | 329 | + <td colspan="14"><h6 class="muted">没有找到相关数据</h6></td> |
| 309 | </tr> | 330 | </tr> |
| 310 | {{/if}} | 331 | {{/if}} |
| 311 | </script> | 332 | </script> |
| 312 | \ No newline at end of file | 333 | \ No newline at end of file |
src/main/resources/static/pages/forms/statement/scheduleDaily.html
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | </div> | 37 | </div> |
| 38 | <div class="form-group"> | 38 | <div class="form-group"> |
| 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> | 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 40 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | 40 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> |
| 41 | </div> | 41 | </div> |
| 42 | </form> | 42 | </form> |
| 43 | </div> | 43 | </div> |
src/main/resources/static/pages/forms/statement/scheduleDailyQp.html
| @@ -61,20 +61,20 @@ | @@ -61,20 +61,20 @@ | ||
| 61 | <th colspan="3" style="text-align:center;vertical-align:middle;">驾驶员</th> | 61 | <th colspan="3" style="text-align:center;vertical-align:middle;">驾驶员</th> |
| 62 | <th colspan="3" style="text-align:center;vertical-align:middle;">售票员</th> | 62 | <th colspan="3" style="text-align:center;vertical-align:middle;">售票员</th> |
| 63 | <th rowspan="3" style="text-align:center;vertical-align:middle;">路牌</th> | 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 | </tr> | 79 | </tr> |
| 80 | <tr> | 80 | <tr> |
| @@ -86,42 +86,55 @@ | @@ -86,42 +86,55 @@ | ||
| 86 | <th rowspan="2">到达</th> | 86 | <th rowspan="2">到达</th> |
| 87 | <th rowspan="2">早/迟</th> | 87 | <th rowspan="2">早/迟</th> |
| 88 | <th rowspan="2">开出</th> | 88 | <th rowspan="2">开出</th> |
| 89 | + <th rowspan="2">备注</th> | ||
| 89 | <th rowspan="2">到达</th> | 90 | <th rowspan="2">到达</th> |
| 90 | <th rowspan="2">早/迟</th> | 91 | <th rowspan="2">早/迟</th> |
| 91 | <th rowspan="2">开出</th> | 92 | <th rowspan="2">开出</th> |
| 93 | + <th rowspan="2">备注</th> | ||
| 92 | <th rowspan="2">到达</th> | 94 | <th rowspan="2">到达</th> |
| 93 | <th rowspan="2">早/迟</th> | 95 | <th rowspan="2">早/迟</th> |
| 94 | <th rowspan="2">开出</th> | 96 | <th rowspan="2">开出</th> |
| 97 | + <th rowspan="2">备注</th> | ||
| 95 | <th rowspan="2">到达</th> | 98 | <th rowspan="2">到达</th> |
| 96 | <th rowspan="2">早/迟</th> | 99 | <th rowspan="2">早/迟</th> |
| 97 | <th rowspan="2">开出</th> | 100 | <th rowspan="2">开出</th> |
| 101 | + <th rowspan="2">备注</th> | ||
| 98 | <th rowspan="2">到达</th> | 102 | <th rowspan="2">到达</th> |
| 99 | <th rowspan="2">早/迟</th> | 103 | <th rowspan="2">早/迟</th> |
| 100 | <th rowspan="2">开出</th> | 104 | <th rowspan="2">开出</th> |
| 105 | + <th rowspan="2">备注</th> | ||
| 101 | <th rowspan="2">到达</th> | 106 | <th rowspan="2">到达</th> |
| 102 | <th rowspan="2">早/迟</th> | 107 | <th rowspan="2">早/迟</th> |
| 103 | <th rowspan="2">开出</th> | 108 | <th rowspan="2">开出</th> |
| 109 | + <th rowspan="2">备注</th> | ||
| 104 | <th rowspan="2">到达</th> | 110 | <th rowspan="2">到达</th> |
| 105 | <th rowspan="2">早/迟</th> | 111 | <th rowspan="2">早/迟</th> |
| 106 | <th rowspan="2">开出</th> | 112 | <th rowspan="2">开出</th> |
| 113 | + <th rowspan="2">备注</th> | ||
| 107 | <th rowspan="2">到达</th> | 114 | <th rowspan="2">到达</th> |
| 108 | <th rowspan="2">早/迟</th> | 115 | <th rowspan="2">早/迟</th> |
| 109 | <th rowspan="2">开出</th> | 116 | <th rowspan="2">开出</th> |
| 117 | + <th rowspan="2">备注</th> | ||
| 110 | <th rowspan="2">到达</th> | 118 | <th rowspan="2">到达</th> |
| 111 | <th rowspan="2">早/迟</th> | 119 | <th rowspan="2">早/迟</th> |
| 112 | <th rowspan="2">开出</th> | 120 | <th rowspan="2">开出</th> |
| 121 | + <th rowspan="2">备注</th> | ||
| 113 | <th rowspan="2">到达</th> | 122 | <th rowspan="2">到达</th> |
| 114 | <th rowspan="2">早/迟</th> | 123 | <th rowspan="2">早/迟</th> |
| 115 | <th rowspan="2">开出</th> | 124 | <th rowspan="2">开出</th> |
| 125 | + <th rowspan="2">备注</th> | ||
| 116 | <th rowspan="2">到达</th> | 126 | <th rowspan="2">到达</th> |
| 117 | <th rowspan="2">早/迟</th> | 127 | <th rowspan="2">早/迟</th> |
| 118 | <th rowspan="2">开出</th> | 128 | <th rowspan="2">开出</th> |
| 129 | + <th rowspan="2">备注</th> | ||
| 119 | <th rowspan="2">到达</th> | 130 | <th rowspan="2">到达</th> |
| 120 | <th rowspan="2">早/迟</th> | 131 | <th rowspan="2">早/迟</th> |
| 121 | <th rowspan="2">开出</th> | 132 | <th rowspan="2">开出</th> |
| 133 | + <th rowspan="2">备注</th> | ||
| 122 | <th rowspan="2">到达</th> | 134 | <th rowspan="2">到达</th> |
| 123 | <th rowspan="2">早/迟</th> | 135 | <th rowspan="2">早/迟</th> |
| 124 | <th rowspan="2">开出</th> | 136 | <th rowspan="2">开出</th> |
| 137 | + <th rowspan="2">备注</th> | ||
| 125 | </tr> | 138 | </tr> |
| 126 | <tr> | 139 | <tr> |
| 127 | <th>出场</th> | 140 | <th>出场</th> |
| @@ -134,17 +147,80 @@ | @@ -134,17 +147,80 @@ | ||
| 134 | </thead> | 147 | </thead> |
| 135 | <tbody> | 148 | <tbody> |
| 136 | <tr > | 149 | <tr > |
| 137 | - <td></td> | 150 | + <td>1</td> |
| 138 | <td> | 151 | <td> |
| 152 | + YT-CD001 | ||
| 139 | </td> | 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 | </td> | 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 | </tr> | 224 | </tr> |
| 149 | 225 | ||
| 150 | </tbody> | 226 | </tbody> |
src/main/resources/static/pages/forms/statement/statisticsDaily .html
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | </div> | 37 | </div> |
| 38 | <div class="form-group"> | 38 | <div class="form-group"> |
| 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> | 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 40 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | 40 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> |
| 41 | </div> | 41 | </div> |
| 42 | </form> | 42 | </form> |
| 43 | </div> | 43 | </div> |
src/main/resources/static/pages/forms/statement/waybill.html
| @@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
| 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> | 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 40 | <input class="btn btn-default" type="button" id="export" value="导出"/> | 40 | <input class="btn btn-default" type="button" id="export" value="导出"/> |
| 41 | <input class="btn btn-default" type="button" id="print" value="打印"/> | 41 | <input class="btn btn-default" type="button" id="print" value="打印"/> |
| 42 | - <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> | 42 | +<!-- <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> --> |
| 43 | </div> | 43 | </div> |
| 44 | </form> | 44 | </form> |
| 45 | </div> | 45 | </div> |
src/main/resources/static/pages/forms/statement/workDaily.html
| @@ -55,11 +55,13 @@ | @@ -55,11 +55,13 @@ | ||
| 55 | <thead> | 55 | <thead> |
| 56 | <tr class="hidden"> | 56 | <tr class="hidden"> |
| 57 | <th width="80px">日期</th> | 57 | <th width="80px">日期</th> |
| 58 | - <th width="100px">线路</th> | 58 | + <th>公司</th> |
| 59 | + <th>分公司</th> | ||
| 60 | + <th>线路</th> | ||
| 59 | <th>计划班次</th> | 61 | <th>计划班次</th> |
| 60 | <th>待发调整</th> | 62 | <th>待发调整</th> |
| 61 | - <th>待发调整比率</th> | ||
| 62 | - <th>出场率</th> | 63 | + <th width="60px">待发调整比率</th> |
| 64 | + <th width="60px">出场率</th> | ||
| 63 | <th width="46px">上行发快</th> | 65 | <th width="46px">上行发快</th> |
| 64 | <th width="46px">上行到快</th> | 66 | <th width="46px">上行到快</th> |
| 65 | <th width="46px">下行发快</th> | 67 | <th width="46px">下行发快</th> |
| @@ -68,9 +70,9 @@ | @@ -68,9 +70,9 @@ | ||
| 68 | <th width="46px">上行到慢</th> | 70 | <th width="46px">上行到慢</th> |
| 69 | <th width="46px">下行发慢</th> | 71 | <th width="46px">下行发慢</th> |
| 70 | <th width="46px">下行到慢</th> | 72 | <th width="46px">下行到慢</th> |
| 71 | - <th>误点总数(快/慢)</th> | ||
| 72 | - <th>首末班准点率</th> | ||
| 73 | - <th>高峰班次执行率(早/晚)</th> | 73 | + <th width="75px">误点总数(快/慢)</th> |
| 74 | + <th width="100px">首末班准点率</th> | ||
| 75 | + <th width="100px">高峰班次执行率(早/晚)</th> | ||
| 74 | </tr> | 76 | </tr> |
| 75 | </thead> | 77 | </thead> |
| 76 | <tbody> | 78 | <tbody> |
| @@ -88,6 +90,7 @@ | @@ -88,6 +90,7 @@ | ||
| 88 | 90 | ||
| 89 | <script> | 91 | <script> |
| 90 | $(function(){ | 92 | $(function(){ |
| 93 | + $('#export').attr('disabled', "true"); | ||
| 91 | 94 | ||
| 92 | // 关闭左侧栏 | 95 | // 关闭左侧栏 |
| 93 | if (!$('body').hasClass('page-sidebar-closed')) | 96 | if (!$('body').hasClass('page-sidebar-closed')) |
| @@ -176,11 +179,21 @@ | @@ -176,11 +179,21 @@ | ||
| 176 | // 把渲染好的模版html文本追加到表格中 | 179 | // 把渲染好的模版html文本追加到表格中 |
| 177 | $('#forms tbody').html(tbodyHtml); | 180 | $('#forms tbody').html(tbodyHtml); |
| 178 | 181 | ||
| 182 | + if(result.length == 0) | ||
| 183 | + $("#export").attr('disabled',"true"); | ||
| 184 | + else | ||
| 185 | + $("#export").removeAttr("disabled"); | ||
| 179 | }); | 186 | }); |
| 180 | } | 187 | } |
| 181 | 188 | ||
| 182 | $("#export").on("click",function(){ | 189 | $("#export").on("click",function(){ |
| 183 | - $get('/pcpc/workDaily',{line:line,date:date,type:'export'},function(result){ | 190 | + var params = {}; |
| 191 | + params['line'] = line; | ||
| 192 | + params['date'] = date; | ||
| 193 | + params['type'] = "export"; | ||
| 194 | + params['company'] = company; | ||
| 195 | + params['subCompany'] = subCompany; | ||
| 196 | + $get('/pcpc/workDaily', params, function(result){ | ||
| 184 | window.open("/downloadFile/download?fileName=营运服务日报表"+moment(date).format("YYYYMMDD")); | 197 | window.open("/downloadFile/download?fileName=营运服务日报表"+moment(date).format("YYYYMMDD")); |
| 185 | }); | 198 | }); |
| 186 | }); | 199 | }); |
| @@ -193,6 +206,8 @@ | @@ -193,6 +206,8 @@ | ||
| 193 | {{each list as obj i}} | 206 | {{each list as obj i}} |
| 194 | <tr> | 207 | <tr> |
| 195 | <td>{{obj.date}}</td> | 208 | <td>{{obj.date}}</td> |
| 209 | + <td>{{obj.company}}</td> | ||
| 210 | + <td>{{obj.subCompany}}</td> | ||
| 196 | <td>{{obj.line}}</td> | 211 | <td>{{obj.line}}</td> |
| 197 | <td>{{obj.jhbc}}</td> | 212 | <td>{{obj.jhbc}}</td> |
| 198 | <td>{{obj.dftz}}</td> | 213 | <td>{{obj.dftz}}</td> |
| @@ -213,7 +228,7 @@ | @@ -213,7 +228,7 @@ | ||
| 213 | {{/each}} | 228 | {{/each}} |
| 214 | {{if list.length == 0}} | 229 | {{if list.length == 0}} |
| 215 | <tr> | 230 | <tr> |
| 216 | - <td colspan="17"><h6 class="muted">没有找到相关数据</h6></td> | 231 | + <td colspan="19"><h6 class="muted">没有找到相关数据</h6></td> |
| 217 | </tr> | 232 | </tr> |
| 218 | {{/if}} | 233 | {{/if}} |
| 219 | </script> | 234 | </script> |
| 220 | \ No newline at end of file | 235 | \ No newline at end of file |
src/main/resources/static/pages/report/inoutstation.html
| @@ -294,17 +294,18 @@ | @@ -294,17 +294,18 @@ | ||
| 294 | var id=params[0].split("\\")[0]; | 294 | var id=params[0].split("\\")[0]; |
| 295 | var fcsj = $('.in_carpark_fcsj[data-id='+id+']', '#forms').html(); | 295 | var fcsj = $('.in_carpark_fcsj[data-id='+id+']', '#forms').html(); |
| 296 | var ddsj= $('.in_carpark_zdsj[data-id='+id+']', '#forms').html(); | 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 | $("#query2").click(function(){ | 311 | $("#query2").click(function(){ |
src/main/resources/static/pages/report/message/message.html
| @@ -41,9 +41,9 @@ | @@ -41,9 +41,9 @@ | ||
| 41 | </div> | 41 | </div> |
| 42 | <div class="form-group" style="display: inline-block;margin-left: 15px;"> | 42 | <div class="form-group" style="display: inline-block;margin-left: 15px;"> |
| 43 | <input class="btn btn-default" type="button" id="query" value="查询"/> | 43 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 44 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | 44 | +<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> |
| 45 | <input class="btn btn-default" type="button" id="print" value="打印"/> | 45 | <input class="btn btn-default" type="button" id="print" value="打印"/> |
| 46 | - <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> | 46 | +<!-- <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> --> |
| 47 | </div> | 47 | </div> |
| 48 | </form> | 48 | </form> |
| 49 | </div> | 49 | </div> |
| @@ -235,12 +235,12 @@ | @@ -235,12 +235,12 @@ | ||
| 235 | {{each list as obj i}} | 235 | {{each list as obj i}} |
| 236 | <tr> | 236 | <tr> |
| 237 | <td>{{i+1}}</td> | 237 | <td>{{i+1}}</td> |
| 238 | + <td>{{obj[4]}}</td> | ||
| 239 | + <td>{{obj[6]}}</td> | ||
| 238 | <td>{{obj[0]}}</td> | 240 | <td>{{obj[0]}}</td> |
| 239 | <td>{{obj[1]}}</td> | 241 | <td>{{obj[1]}}</td> |
| 240 | - <td>{{obj[2]}}</td> | ||
| 241 | <td>{{obj[3]}}</td> | 242 | <td>{{obj[3]}}</td> |
| 242 | - <td>{{obj[4]}}</td> | ||
| 243 | - <td>{{obj[5]}}</td> | 243 | + <td>{{obj[2]}}</td> |
| 244 | </tr> | 244 | </tr> |
| 245 | {{/each}} | 245 | {{/each}} |
| 246 | {{if list.length == 0}} | 246 | {{if list.length == 0}} |
src/main/resources/static/pages/report/timetable/timetable.html
| @@ -141,21 +141,21 @@ | @@ -141,21 +141,21 @@ | ||
| 141 | <div class="portlet-body"> | 141 | <div class="portlet-body"> |
| 142 | <div class="row"> | 142 | <div class="row"> |
| 143 | <div class="col-md-6" > | 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 | <tr> | 145 | <tr> |
| 146 | <td colspan="6">调度形式</td> | 146 | <td colspan="6">调度形式</td> |
| 147 | </tr> | 147 | </tr> |
| 148 | <tr> | 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 | </tr> | 151 | </tr> |
| 152 | <tr> | 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 | </tr> | 159 | </tr> |
| 160 | <tbody class="tbody_time_4"> | 160 | <tbody class="tbody_time_4"> |
| 161 | 161 | ||
| @@ -283,26 +283,25 @@ | @@ -283,26 +283,25 @@ | ||
| 283 | $.get('/report/tbodyTime2',{line:line,ttinfo:ttinfo},function(result){ | 283 | $.get('/report/tbodyTime2',{line:line,ttinfo:ttinfo},function(result){ |
| 284 | var tbodyTime2 = template('tbodyTime2',{map:result}); | 284 | var tbodyTime2 = template('tbodyTime2',{map:result}); |
| 285 | $('#formsTime2 .tbody_time_2').html(tbodyTime2); | 285 | $('#formsTime2 .tbody_time_2').html(tbodyTime2); |
| 286 | - });/* | 286 | + }); |
| 287 | $.get('/report/tbodyTime3',{line:line,ttinfo:ttinfo},function(result){ | 287 | $.get('/report/tbodyTime3',{line:line,ttinfo:ttinfo},function(result){ |
| 288 | - | ||
| 289 | var tbodyTime3 = template('tbodyTime3',{list:result}); | 288 | var tbodyTime3 = template('tbodyTime3',{list:result}); |
| 290 | $('#formsTime3 .tbody_time_3').html(tbodyTime3); | 289 | $('#formsTime3 .tbody_time_3').html(tbodyTime3); |
| 291 | var divTime3 = window.document.getElementById('formsTime3'); | 290 | var divTime3 = window.document.getElementById('formsTime3'); |
| 292 | var divTime2 = window.document.getElementById('formsTime2'); | 291 | var divTime2 = window.document.getElementById('formsTime2'); |
| 293 | - console.log(divTime3.offsetHeight); | ||
| 294 | divTime2.style.height=divTime3.offsetHeight+"px"; | 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 | var tbodyTime5 = template('tbodyTime5',{list:result}); | 302 | var tbodyTime5 = template('tbodyTime5',{list:result}); |
| 304 | $('#formsTime5 .tbody_time_5').html(tbodyTime5); | 303 | $('#formsTime5 .tbody_time_5').html(tbodyTime5); |
| 305 | - }); */ | 304 | + }); |
| 306 | } | 305 | } |
| 307 | 306 | ||
| 308 | 307 | ||
| @@ -352,6 +351,27 @@ | @@ -352,6 +351,27 @@ | ||
| 352 | </script> | 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 | <script type="text/html" id="tbodyTime5"> | 375 | <script type="text/html" id="tbodyTime5"> |
| 356 | {{each list as result i}} | 376 | {{each list as result i}} |
| 357 | <tr> | 377 | <tr> |