Commit e17bae2bb8c672b38b891b8ad26ec5fac20f65f6
1 parent
0e3171c4
1.互联网公交实时GPS接口开放
Showing
4 changed files
with
233 additions
and
216 deletions
src/main/java/com/bsth/StartCommand.java
| 1 | -package com.bsth; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import com.bsth.server_rs.gps.buffer.GpsRefreshThread; | ||
| 5 | -import com.bsth.server_rs.schedule.real.thread.ExecSchDataRefreshThread; | ||
| 6 | -import com.bsth.server_rs.schedule.real.thread.SchInOutDataRefreshThread; | ||
| 7 | -import com.bsth.server_rs.thread.RfidCardInfoPersistenceThread; | ||
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | -import org.springframework.boot.CommandLineRunner; | ||
| 10 | -import org.springframework.stereotype.Component; | ||
| 11 | - | ||
| 12 | -import java.util.concurrent.ScheduledExecutorService; | ||
| 13 | -import java.util.concurrent.TimeUnit; | ||
| 14 | - | ||
| 15 | - | ||
| 16 | -/** | ||
| 17 | - * 随应用启动运行 | ||
| 18 | - * @author PanZhao | ||
| 19 | - * | ||
| 20 | - */ | ||
| 21 | -@Component | ||
| 22 | -public class StartCommand implements CommandLineRunner{ | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - @Autowired | ||
| 26 | - RfidCardInfoPersistenceThread rfidCardInfoPersistenceThread; | ||
| 27 | - @Autowired | ||
| 28 | - SchInOutDataRefreshThread schInOutDataRefreshThread; | ||
| 29 | - @Autowired | ||
| 30 | - ExecSchDataRefreshThread execSchDataRefreshThread; | ||
| 31 | - @Autowired | ||
| 32 | - GpsRefreshThread gpsRefreshThread; | ||
| 33 | - | ||
| 34 | - @Override | ||
| 35 | - public void run(String... arg0){ | ||
| 36 | - | ||
| 37 | - try { | ||
| 38 | - ScheduledExecutorService sexec = Application.mainServices; | ||
| 39 | - //定时将人车卡数据入库 | ||
| 40 | - sexec.scheduleWithFixedDelay(rfidCardInfoPersistenceThread, 120, 60 * 10, TimeUnit.SECONDS); | ||
| 41 | - //定时从调度系统刷新进出场数据 | ||
| 42 | - sexec.scheduleWithFixedDelay(schInOutDataRefreshThread, 40, 60, TimeUnit.SECONDS); | ||
| 43 | - //定时从调度系统刷新车辆正在的执行班次 | ||
| 44 | - sexec.scheduleWithFixedDelay(execSchDataRefreshThread, 20, 60, TimeUnit.SECONDS); | ||
| 45 | - //定时刷新实时gps缓存 | ||
| 46 | - Application.mainServices.scheduleWithFixedDelay(gpsRefreshThread, 10, 7, TimeUnit.SECONDS); | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - } catch (Exception e) { | ||
| 50 | - e.printStackTrace(); | ||
| 51 | - } | ||
| 52 | - } | ||
| 53 | -} | 1 | +package com.bsth; |
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.bsth.server_rs.gps.buffer.BasicDataRefreshThread; | ||
| 5 | +import com.bsth.server_rs.gps.buffer.GpsRefreshThread; | ||
| 6 | +import com.bsth.server_rs.schedule.real.thread.ExecSchDataRefreshThread; | ||
| 7 | +import com.bsth.server_rs.schedule.real.thread.SchInOutDataRefreshThread; | ||
| 8 | +import com.bsth.server_rs.thread.RfidCardInfoPersistenceThread; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.boot.CommandLineRunner; | ||
| 11 | +import org.springframework.stereotype.Component; | ||
| 12 | + | ||
| 13 | +import java.util.concurrent.ScheduledExecutorService; | ||
| 14 | +import java.util.concurrent.TimeUnit; | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 随应用启动运行 | ||
| 19 | + * @author PanZhao | ||
| 20 | + * | ||
| 21 | + */ | ||
| 22 | +@Component | ||
| 23 | +public class StartCommand implements CommandLineRunner{ | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + @Autowired | ||
| 27 | + RfidCardInfoPersistenceThread rfidCardInfoPersistenceThread; | ||
| 28 | + @Autowired | ||
| 29 | + SchInOutDataRefreshThread schInOutDataRefreshThread; | ||
| 30 | + @Autowired | ||
| 31 | + ExecSchDataRefreshThread execSchDataRefreshThread; | ||
| 32 | + @Autowired | ||
| 33 | + GpsRefreshThread gpsRefreshThread; | ||
| 34 | + @Autowired | ||
| 35 | + BasicDataRefreshThread basicDataRefreshThread; | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void run(String... arg0){ | ||
| 39 | + | ||
| 40 | + try { | ||
| 41 | + ScheduledExecutorService sexec = Application.mainServices; | ||
| 42 | + //定时将人车卡数据入库 | ||
| 43 | + sexec.scheduleWithFixedDelay(rfidCardInfoPersistenceThread, 120, 60 * 10, TimeUnit.SECONDS); | ||
| 44 | + //定时从调度系统刷新进出场数据 | ||
| 45 | + sexec.scheduleWithFixedDelay(schInOutDataRefreshThread, 40, 60, TimeUnit.SECONDS); | ||
| 46 | + //定时从调度系统刷新车辆正在的执行班次 | ||
| 47 | + sexec.scheduleWithFixedDelay(execSchDataRefreshThread, 20, 60, TimeUnit.SECONDS); | ||
| 48 | + //定时刷新实时gps缓存 | ||
| 49 | + Application.mainServices.scheduleWithFixedDelay(gpsRefreshThread, 10, 7, TimeUnit.SECONDS); | ||
| 50 | + //定时刷新基础信息 | ||
| 51 | + Application.mainServices.scheduleWithFixedDelay(basicDataRefreshThread, 30, 30, TimeUnit.MINUTES); | ||
| 52 | + | ||
| 53 | + } catch (Exception e) { | ||
| 54 | + e.printStackTrace(); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | +} |
src/main/java/com/bsth/server_rs/gps/GpsRestService.java
| @@ -62,10 +62,10 @@ public class GpsRestService { | @@ -62,10 +62,10 @@ public class GpsRestService { | ||
| 62 | public List<Map<String, Object>> gpsReport() { | 62 | public List<Map<String, Object>> gpsReport() { |
| 63 | List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); | 63 | List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); |
| 64 | Collection<GpsEntity> gpss = GpsRealDataBuffer.all(); | 64 | Collection<GpsEntity> gpss = GpsRealDataBuffer.all(); |
| 65 | - Set<String> devices = BasicDataBuffer.getAllDevice(); | 65 | + Set<Integer> lines = BasicDataBuffer.getAllLine(); |
| 66 | for (GpsEntity gps : gpss) { | 66 | for (GpsEntity gps : gpss) { |
| 67 | String device = gps.getDeviceId(); | 67 | String device = gps.getDeviceId(); |
| 68 | - if (devices.contains(device)) { | 68 | + if (lines.contains(Integer.parseInt(gps.getLineId()))) { |
| 69 | Map<String, Object> map = new HashMap<String, Object>(); | 69 | Map<String, Object> map = new HashMap<String, Object>(); |
| 70 | map.put("vehicleNumberPlate", BasicDataBuffer.getPlateByDevice(device)); | 70 | map.put("vehicleNumberPlate", BasicDataBuffer.getPlateByDevice(device)); |
| 71 | try { | 71 | try { |
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataBuffer.java
| 1 | -package com.bsth.server_rs.gps.buffer; | ||
| 2 | - | ||
| 3 | -import java.util.HashMap; | ||
| 4 | -import java.util.Map; | ||
| 5 | -import java.util.Set; | ||
| 6 | - | ||
| 7 | -import org.springframework.stereotype.Component; | ||
| 8 | - | ||
| 9 | -import com.bsth.server_rs.gps.entity.LineInfo; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * Created by panzhao on 2017/3/30. | ||
| 13 | - */ | ||
| 14 | -@Component | ||
| 15 | -public class BasicDataBuffer { | ||
| 16 | - | ||
| 17 | - private static Map<Integer, LineInfo> LINEID_INFO = new HashMap<Integer, LineInfo>(); | ||
| 18 | - | ||
| 19 | - private static Map<String, String> DEVICE_PLATE = new HashMap<String, String>(); | ||
| 20 | - | ||
| 21 | - public static void putLine(Integer lineId, LineInfo info) { | ||
| 22 | - LINEID_INFO.put(lineId, info); | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - public static void putCar(String deviceId, String plateNo) { | ||
| 26 | - DEVICE_PLATE.put(deviceId, plateNo); | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - public static String getPlateByDevice(String deviceId) { | ||
| 30 | - return DEVICE_PLATE.get(deviceId); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - public static Set<String> getAllDevice() { | ||
| 34 | - return DEVICE_PLATE.keySet(); | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - public static LineInfo getLineById(Integer lineId) { | ||
| 38 | - return LINEID_INFO.get(lineId); | ||
| 39 | - } | ||
| 40 | -} | 1 | +package com.bsth.server_rs.gps.buffer; |
| 2 | + | ||
| 3 | +import java.util.HashMap; | ||
| 4 | +import java.util.Map; | ||
| 5 | +import java.util.Set; | ||
| 6 | + | ||
| 7 | +import org.springframework.stereotype.Component; | ||
| 8 | + | ||
| 9 | +import com.bsth.server_rs.gps.entity.LineInfo; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Created by panzhao on 2017/3/30. | ||
| 13 | + */ | ||
| 14 | +@Component | ||
| 15 | +public class BasicDataBuffer { | ||
| 16 | + | ||
| 17 | + private static Map<Integer, LineInfo> LINEID_INFO = new HashMap<Integer, LineInfo>(); | ||
| 18 | + | ||
| 19 | + private static Map<String, String> DEVICE_PLATE = new HashMap<String, String>(); | ||
| 20 | + | ||
| 21 | + public static void putLine(Integer lineId, LineInfo info) { | ||
| 22 | + LINEID_INFO.put(lineId, info); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public static void putCar(String deviceId, String plateNo) { | ||
| 26 | + DEVICE_PLATE.put(deviceId, plateNo); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public static String getPlateByDevice(String deviceId) { | ||
| 30 | + return DEVICE_PLATE.get(deviceId); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public static Set<Integer> getAllLine() { | ||
| 34 | + return LINEID_INFO.keySet(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public static LineInfo getLineById(Integer lineId) { | ||
| 38 | + return LINEID_INFO.get(lineId); | ||
| 39 | + } | ||
| 40 | +} |
src/main/java/com/bsth/server_rs/gps/buffer/BasicDataRefreshThread.java
| 1 | -package com.bsth.server_rs.gps.buffer; | ||
| 2 | - | ||
| 3 | -import java.sql.ResultSet; | ||
| 4 | -import java.sql.SQLException; | ||
| 5 | -import java.util.ArrayList; | ||
| 6 | -import java.util.List; | ||
| 7 | -import java.util.Map; | ||
| 8 | - | ||
| 9 | -import org.slf4j.Logger; | ||
| 10 | -import org.slf4j.LoggerFactory; | ||
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 13 | -import org.springframework.jdbc.core.RowMapper; | ||
| 14 | -import org.springframework.stereotype.Component; | ||
| 15 | - | ||
| 16 | -import com.bsth.server_rs.gps.entity.LineInfo; | ||
| 17 | -import com.bsth.server_rs.gps.entity.Point; | ||
| 18 | -import com.bsth.server_rs.gps.entity.StopInfo; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * Created by panzhao on 2017/3/30. | ||
| 22 | - */ | ||
| 23 | -@Component | ||
| 24 | -public class BasicDataRefreshThread extends Thread{ | ||
| 25 | - | ||
| 26 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 27 | - | ||
| 28 | - @Autowired | ||
| 29 | - private JdbcTemplate jdbcTemplate; | ||
| 30 | - | ||
| 31 | - @Override | ||
| 32 | - public void run() { | ||
| 33 | - try { | ||
| 34 | - String qline = "select a.id,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,shanghai_linecode,line_play_type,up_travel_time,down_travel_time from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0"; | ||
| 35 | - String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code"; | ||
| 36 | - String qcar = "select equipment_code device_id, car_plate plate_no from bsth_c_cars a where a.supplier_name = 3"; | ||
| 37 | - | ||
| 38 | - List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo()); | ||
| 39 | - List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo()); | ||
| 40 | - List<Map<String, Object>> cars = jdbcTemplate.queryForList(qcar); | ||
| 41 | - | ||
| 42 | - // 缓存线路基本信息 | ||
| 43 | - for (LineInfo line : lines) { | ||
| 44 | - BasicDataBuffer.putLine(line.getLineId(), line); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - // 线路信息中添加上下行站点信息 | ||
| 48 | - int oldId = -1; | ||
| 49 | - LineInfo line = null; | ||
| 50 | - for (StopInfo stop : stops) { | ||
| 51 | - if (stop.getLineCode() != oldId) { | ||
| 52 | - oldId = stop.getLineCode(); | ||
| 53 | - line = BasicDataBuffer.getLineById(oldId); | ||
| 54 | - } | ||
| 55 | - if (line != null) { | ||
| 56 | - if (stop.getDirections() == 0) line.getStopsUp().add(stop); | ||
| 57 | - else line.getStopsDown().add(stop); | ||
| 58 | - } | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - for (Map<String, Object> car : cars) { | ||
| 62 | - BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no")); | ||
| 63 | - } | ||
| 64 | - }catch (Exception e){ | ||
| 65 | - logger.error("", e); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - final class RowMapperLineInfo implements RowMapper<LineInfo> { | ||
| 70 | - | ||
| 71 | - @Override | ||
| 72 | - public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 73 | - // TODO Auto-generated method stub | ||
| 74 | - LineInfo line = new LineInfo(); | ||
| 75 | - line.setId(rs.getInt("id")); | ||
| 76 | - line.setInUse(rs.getInt("in_use")); | ||
| 77 | - line.setLineId(rs.getInt("line_code")); | ||
| 78 | - line.setLineName(rs.getString("name")); | ||
| 79 | - //line.setStartStation(rs.getInt("start_station")); | ||
| 80 | - line.setStartStationName(rs.getString("start_station_name")); | ||
| 81 | - line.setStartStationFirstTime(rs.getString("start_station_first_time")); | ||
| 82 | - line.setStartStationEndTime(rs.getString("start_station_end_time")); | ||
| 83 | - //line.setEndStation(rs.getInt("end_station")); | ||
| 84 | - line.setEndStationName(rs.getString("end_station_name")); | ||
| 85 | - line.setEndStationFirstTime(rs.getString("end_station_first_time")); | ||
| 86 | - line.setEndStationEndTime(rs.getString("end_station_end_time")); | ||
| 87 | - line.setCompany(rs.getString("company")); | ||
| 88 | - line.setBrancheCompany(rs.getString("branche_company")); | ||
| 89 | - line.setTelephone(rs.getString("telephone")); | ||
| 90 | - line.setLinePlayType(rs.getInt("line_play_type")); | ||
| 91 | - return line; | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - final class RowMapperStopInfo implements RowMapper<StopInfo> { | ||
| 97 | - | ||
| 98 | - @Override | ||
| 99 | - public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 100 | - // TODO Auto-generated method stub | ||
| 101 | - StopInfo stop = new StopInfo(); | ||
| 102 | - stop.setId(rs.getInt("id")); | ||
| 103 | - stop.setStationCod(rs.getString("station_cod")); | ||
| 104 | - stop.setStationName(rs.getString("station_name")); | ||
| 105 | - //stop.setStationType(rs.getString("station_type")); | ||
| 106 | - stop.setRoadCoding(rs.getString("road_coding")); | ||
| 107 | - float lon = rs.getFloat("g_lonx"); | ||
| 108 | - float lat = rs.getFloat("g_laty"); | ||
| 109 | - stop.setPoint(new Point(lon, lat)); | ||
| 110 | - stop.setLineId(rs.getInt("line")); | ||
| 111 | - stop.setLineCode(rs.getInt("line_code")); | ||
| 112 | - stop.setDirections(rs.getInt("directions")); | ||
| 113 | - stop.setShapesType(rs.getString("shapes_type")); | ||
| 114 | - stop.setRadius(rs.getInt("radius")); | ||
| 115 | - stop.setPoints(new ArrayList<Point>()); | ||
| 116 | - stop.setDistances(rs.getDouble("distances")*1000); | ||
| 117 | - return stop; | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - } | ||
| 121 | -} | 1 | +package com.bsth.server_rs.gps.buffer; |
| 2 | + | ||
| 3 | +import java.sql.ResultSet; | ||
| 4 | +import java.sql.SQLException; | ||
| 5 | +import java.util.ArrayList; | ||
| 6 | +import java.util.List; | ||
| 7 | +import java.util.Map; | ||
| 8 | + | ||
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 11 | +import org.springframework.beans.factory.InitializingBean; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 14 | +import org.springframework.jdbc.core.RowMapper; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | + | ||
| 17 | +import com.bsth.server_rs.gps.entity.LineInfo; | ||
| 18 | +import com.bsth.server_rs.gps.entity.Point; | ||
| 19 | +import com.bsth.server_rs.gps.entity.StopInfo; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Created by panzhao on 2017/3/30. | ||
| 23 | + */ | ||
| 24 | +@Component | ||
| 25 | +public class BasicDataRefreshThread extends Thread implements InitializingBean { | ||
| 26 | + | ||
| 27 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + private JdbcTemplate jdbcTemplate; | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public void run() { | ||
| 34 | + loadBasicData(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + private void loadBasicData() { | ||
| 38 | + try { | ||
| 39 | + String qline = "select a.id,in_use,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,shanghai_linecode,line_play_type,up_travel_time,down_travel_time from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0 and a.nature = 'hlwgj'"; | ||
| 40 | + String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code"; | ||
| 41 | + String qcar = "select equipment_code device_id, car_plate plate_no from bsth_c_cars"; | ||
| 42 | + | ||
| 43 | + List<LineInfo> lines = jdbcTemplate.query(qline, new RowMapperLineInfo()); | ||
| 44 | + List<StopInfo> stops = jdbcTemplate.query(qstop, new RowMapperStopInfo()); | ||
| 45 | + List<Map<String, Object>> cars = jdbcTemplate.queryForList(qcar); | ||
| 46 | + | ||
| 47 | + // 缓存线路基本信息 | ||
| 48 | + for (LineInfo line : lines) { | ||
| 49 | + BasicDataBuffer.putLine(line.getLineId(), line); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + // 线路信息中添加上下行站点信息 | ||
| 53 | + int oldId = -1; | ||
| 54 | + LineInfo line = null; | ||
| 55 | + for (StopInfo stop : stops) { | ||
| 56 | + if (stop.getLineCode() != oldId) { | ||
| 57 | + oldId = stop.getLineCode(); | ||
| 58 | + line = BasicDataBuffer.getLineById(oldId); | ||
| 59 | + } | ||
| 60 | + if (line != null) { | ||
| 61 | + if (stop.getDirections() == 0) line.getStopsUp().add(stop); | ||
| 62 | + else line.getStopsDown().add(stop); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + for (Map<String, Object> car : cars) { | ||
| 67 | + BasicDataBuffer.putCar((String)car.get("device_id"), (String)car.get("plate_no")); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + logger.info("基础数据加载成功"); | ||
| 71 | + }catch (Exception e){ | ||
| 72 | + logger.error("基础数据加载失败", e); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + final class RowMapperLineInfo implements RowMapper<LineInfo> { | ||
| 77 | + | ||
| 78 | + @Override | ||
| 79 | + public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 80 | + // TODO Auto-generated method stub | ||
| 81 | + LineInfo line = new LineInfo(); | ||
| 82 | + line.setId(rs.getInt("id")); | ||
| 83 | + line.setInUse(rs.getInt("in_use")); | ||
| 84 | + line.setLineId(rs.getInt("line_code")); | ||
| 85 | + line.setLineName(rs.getString("name")); | ||
| 86 | + //line.setStartStation(rs.getInt("start_station")); | ||
| 87 | + line.setStartStationName(rs.getString("start_station_name")); | ||
| 88 | + line.setStartStationFirstTime(rs.getString("start_station_first_time")); | ||
| 89 | + line.setStartStationEndTime(rs.getString("start_station_end_time")); | ||
| 90 | + //line.setEndStation(rs.getInt("end_station")); | ||
| 91 | + line.setEndStationName(rs.getString("end_station_name")); | ||
| 92 | + line.setEndStationFirstTime(rs.getString("end_station_first_time")); | ||
| 93 | + line.setEndStationEndTime(rs.getString("end_station_end_time")); | ||
| 94 | + line.setCompany(rs.getString("company")); | ||
| 95 | + line.setBrancheCompany(rs.getString("branche_company")); | ||
| 96 | + line.setTelephone(rs.getString("telephone")); | ||
| 97 | + line.setLinePlayType(rs.getInt("line_play_type")); | ||
| 98 | + return line; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + final class RowMapperStopInfo implements RowMapper<StopInfo> { | ||
| 104 | + | ||
| 105 | + @Override | ||
| 106 | + public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 107 | + // TODO Auto-generated method stub | ||
| 108 | + StopInfo stop = new StopInfo(); | ||
| 109 | + stop.setId(rs.getInt("id")); | ||
| 110 | + stop.setStationCod(rs.getString("station_cod")); | ||
| 111 | + stop.setStationName(rs.getString("station_name")); | ||
| 112 | + //stop.setStationType(rs.getString("station_type")); | ||
| 113 | + stop.setRoadCoding(rs.getString("road_coding")); | ||
| 114 | + float lon = rs.getFloat("g_lonx"); | ||
| 115 | + float lat = rs.getFloat("g_laty"); | ||
| 116 | + stop.setPoint(new Point(lon, lat)); | ||
| 117 | + stop.setLineId(rs.getInt("line")); | ||
| 118 | + stop.setLineCode(rs.getInt("line_code")); | ||
| 119 | + stop.setDirections(rs.getInt("directions")); | ||
| 120 | + stop.setShapesType(rs.getString("shapes_type")); | ||
| 121 | + stop.setRadius(rs.getInt("radius")); | ||
| 122 | + stop.setPoints(new ArrayList<Point>()); | ||
| 123 | + stop.setDistances(rs.getDouble("distances")*1000); | ||
| 124 | + return stop; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + @Override | ||
| 130 | + public void afterPropertiesSet() throws Exception { | ||
| 131 | + // TODO Auto-generated method stub | ||
| 132 | + loadBasicData(); | ||
| 133 | + } | ||
| 134 | +} |