Commit ea49ae6f9b51ad644b96b53b5ba5d4b5f5849a11
update
Showing
7 changed files
with
262 additions
and
270 deletions
Too many changes to show.
To preserve performance only 7 of 10 files are displayed.
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
| 1 | -package com.bsth.controller.realcontrol; | |
| 2 | - | |
| 3 | -import com.bsth.service.realcontrol.RealMapService; | |
| 4 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 6 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 7 | -import org.springframework.web.bind.annotation.RestController; | |
| 8 | - | |
| 9 | -import java.util.Map; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 线调 地图监控相关 | |
| 13 | - * Created by panzhao on 2016/11/23. | |
| 14 | - */ | |
| 15 | -@RestController | |
| 16 | -@RequestMapping("realMap") | |
| 17 | -public class RealMapController { | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - RealMapService realMapService; | |
| 21 | - | |
| 22 | - /** | |
| 23 | - * 根据线路获取站点路由及空间数据 | |
| 24 | - */ | |
| 25 | - @RequestMapping(value = "/stationSpatialData") | |
| 26 | - public Map<String, Object> stationSpatialData(@RequestParam String idx){ | |
| 27 | - return realMapService.stationSpatialData(idx); | |
| 28 | - } | |
| 29 | -} | |
| 1 | +package com.bsth.controller.realcontrol; | |
| 2 | + | |
| 3 | +import com.bsth.service.realcontrol.RealMapService; | |
| 4 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 6 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 7 | +import org.springframework.web.bind.annotation.RestController; | |
| 8 | + | |
| 9 | +import java.util.Map; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 线调 地图监控相关 | |
| 13 | + * Created by panzhao on 2016/11/23. | |
| 14 | + */ | |
| 15 | +@RestController | |
| 16 | +@RequestMapping("realMap") | |
| 17 | +public class RealMapController { | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + RealMapService realMapService; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 根据线路获取站点路由及空间数据 | |
| 24 | + */ | |
| 25 | + @RequestMapping(value = "/stationSpatialData") | |
| 26 | + public Map<String, Object> stationSpatialData(@RequestParam String idx){ | |
| 27 | + return realMapService.stationSpatialData(idx); | |
| 28 | + } | |
| 29 | +} | ... | ... |
src/main/java/com/bsth/controller/realcontrol/dto/StationSpatialData.java
| 1 | -package com.bsth.controller.realcontrol.dto; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Created by panzhao on 2016/11/23. | |
| 5 | - */ | |
| 6 | -public class StationSpatialData { | |
| 7 | - | |
| 8 | - private String lineCode; | |
| 9 | - | |
| 10 | - private String stationName; | |
| 11 | - | |
| 12 | - private String stationCode; | |
| 13 | - | |
| 14 | - private String stationMark; | |
| 15 | - | |
| 16 | - private int directions; | |
| 17 | - | |
| 18 | - private Float distances; | |
| 19 | - | |
| 20 | - private Float toTime; | |
| 21 | - | |
| 22 | - private Integer versions; | |
| 23 | - | |
| 24 | - private Float gLonx; | |
| 25 | - | |
| 26 | - private Float gLaty; | |
| 27 | - | |
| 28 | - private Float radius; | |
| 29 | - | |
| 30 | - private String shapesType; | |
| 31 | - | |
| 32 | - private String gPolygonGrid; | |
| 33 | - | |
| 34 | - private Integer stationRouteCode; | |
| 35 | - | |
| 36 | - public String getLineCode() { | |
| 37 | - return lineCode; | |
| 38 | - } | |
| 39 | - | |
| 40 | - public void setLineCode(String lineCode) { | |
| 41 | - this.lineCode = lineCode; | |
| 42 | - } | |
| 43 | - | |
| 44 | - public String getStationName() { | |
| 45 | - return stationName; | |
| 46 | - } | |
| 47 | - | |
| 48 | - public void setStationName(String stationName) { | |
| 49 | - this.stationName = stationName; | |
| 50 | - } | |
| 51 | - | |
| 52 | - public String getStationCode() { | |
| 53 | - return stationCode; | |
| 54 | - } | |
| 55 | - | |
| 56 | - public void setStationCode(String stationCode) { | |
| 57 | - this.stationCode = stationCode; | |
| 58 | - } | |
| 59 | - | |
| 60 | - public String getStationMark() { | |
| 61 | - return stationMark; | |
| 62 | - } | |
| 63 | - | |
| 64 | - public void setStationMark(String stationMark) { | |
| 65 | - this.stationMark = stationMark; | |
| 66 | - } | |
| 67 | - | |
| 68 | - public int getDirections() { | |
| 69 | - return directions; | |
| 70 | - } | |
| 71 | - | |
| 72 | - public void setDirections(int directions) { | |
| 73 | - this.directions = directions; | |
| 74 | - } | |
| 75 | - | |
| 76 | - public Float getDistances() { | |
| 77 | - return distances; | |
| 78 | - } | |
| 79 | - | |
| 80 | - public void setDistances(Float distances) { | |
| 81 | - this.distances = distances; | |
| 82 | - } | |
| 83 | - | |
| 84 | - public Float getToTime() { | |
| 85 | - return toTime; | |
| 86 | - } | |
| 87 | - | |
| 88 | - public void setToTime(Float toTime) { | |
| 89 | - this.toTime = toTime; | |
| 90 | - } | |
| 91 | - | |
| 92 | - public Integer getVersions() { | |
| 93 | - return versions; | |
| 94 | - } | |
| 95 | - | |
| 96 | - public void setVersions(Integer versions) { | |
| 97 | - this.versions = versions; | |
| 98 | - } | |
| 99 | - | |
| 100 | - public Float getgLonx() { | |
| 101 | - return gLonx; | |
| 102 | - } | |
| 103 | - | |
| 104 | - public void setgLonx(Float gLonx) { | |
| 105 | - this.gLonx = gLonx; | |
| 106 | - } | |
| 107 | - | |
| 108 | - public Float getgLaty() { | |
| 109 | - return gLaty; | |
| 110 | - } | |
| 111 | - | |
| 112 | - public void setgLaty(Float gLaty) { | |
| 113 | - this.gLaty = gLaty; | |
| 114 | - } | |
| 115 | - | |
| 116 | - public Float getRadius() { | |
| 117 | - return radius; | |
| 118 | - } | |
| 119 | - | |
| 120 | - public void setRadius(Float radius) { | |
| 121 | - this.radius = radius; | |
| 122 | - } | |
| 123 | - | |
| 124 | - public String getShapesType() { | |
| 125 | - return shapesType; | |
| 126 | - } | |
| 127 | - | |
| 128 | - public void setShapesType(String shapesType) { | |
| 129 | - this.shapesType = shapesType; | |
| 130 | - } | |
| 131 | - | |
| 132 | - public String getgPolygonGrid() { | |
| 133 | - return gPolygonGrid; | |
| 134 | - } | |
| 135 | - | |
| 136 | - public void setgPolygonGrid(String gPolygonGrid) { | |
| 137 | - this.gPolygonGrid = gPolygonGrid; | |
| 138 | - } | |
| 139 | - | |
| 140 | - public Integer getStationRouteCode() { | |
| 141 | - return stationRouteCode; | |
| 142 | - } | |
| 143 | - | |
| 144 | - public void setStationRouteCode(Integer stationRouteCode) { | |
| 145 | - this.stationRouteCode = stationRouteCode; | |
| 146 | - } | |
| 147 | -} | |
| 1 | +package com.bsth.controller.realcontrol.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by panzhao on 2016/11/23. | |
| 5 | + */ | |
| 6 | +public class StationSpatialData { | |
| 7 | + | |
| 8 | + private String lineCode; | |
| 9 | + | |
| 10 | + private String stationName; | |
| 11 | + | |
| 12 | + private String stationCode; | |
| 13 | + | |
| 14 | + private String stationMark; | |
| 15 | + | |
| 16 | + private int directions; | |
| 17 | + | |
| 18 | + private Float distances; | |
| 19 | + | |
| 20 | + private Float toTime; | |
| 21 | + | |
| 22 | + private Integer versions; | |
| 23 | + | |
| 24 | + private Float gLonx; | |
| 25 | + | |
| 26 | + private Float gLaty; | |
| 27 | + | |
| 28 | + private Float radius; | |
| 29 | + | |
| 30 | + private String shapesType; | |
| 31 | + | |
| 32 | + private String gPolygonGrid; | |
| 33 | + | |
| 34 | + private Integer stationRouteCode; | |
| 35 | + | |
| 36 | + public String getLineCode() { | |
| 37 | + return lineCode; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setLineCode(String lineCode) { | |
| 41 | + this.lineCode = lineCode; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public String getStationName() { | |
| 45 | + return stationName; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setStationName(String stationName) { | |
| 49 | + this.stationName = stationName; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public String getStationCode() { | |
| 53 | + return stationCode; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public void setStationCode(String stationCode) { | |
| 57 | + this.stationCode = stationCode; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public String getStationMark() { | |
| 61 | + return stationMark; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setStationMark(String stationMark) { | |
| 65 | + this.stationMark = stationMark; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public int getDirections() { | |
| 69 | + return directions; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public void setDirections(int directions) { | |
| 73 | + this.directions = directions; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public Float getDistances() { | |
| 77 | + return distances; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void setDistances(Float distances) { | |
| 81 | + this.distances = distances; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public Float getToTime() { | |
| 85 | + return toTime; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void setToTime(Float toTime) { | |
| 89 | + this.toTime = toTime; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public Integer getVersions() { | |
| 93 | + return versions; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setVersions(Integer versions) { | |
| 97 | + this.versions = versions; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public Float getgLonx() { | |
| 101 | + return gLonx; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void setgLonx(Float gLonx) { | |
| 105 | + this.gLonx = gLonx; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public Float getgLaty() { | |
| 109 | + return gLaty; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public void setgLaty(Float gLaty) { | |
| 113 | + this.gLaty = gLaty; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public Float getRadius() { | |
| 117 | + return radius; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public void setRadius(Float radius) { | |
| 121 | + this.radius = radius; | |
| 122 | + } | |
| 123 | + | |
| 124 | + public String getShapesType() { | |
| 125 | + return shapesType; | |
| 126 | + } | |
| 127 | + | |
| 128 | + public void setShapesType(String shapesType) { | |
| 129 | + this.shapesType = shapesType; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public String getgPolygonGrid() { | |
| 133 | + return gPolygonGrid; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public void setgPolygonGrid(String gPolygonGrid) { | |
| 137 | + this.gPolygonGrid = gPolygonGrid; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public Integer getStationRouteCode() { | |
| 141 | + return stationRouteCode; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public void setStationRouteCode(Integer stationRouteCode) { | |
| 145 | + this.stationRouteCode = stationRouteCode; | |
| 146 | + } | |
| 147 | +} | ... | ... |
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
| 1 | 1 | package com.bsth.data.arrival; |
| 2 | 2 | |
| 3 | +import com.bsth.Application; | |
| 3 | 4 | import com.bsth.data.match.Arrival2Schedule; |
| 4 | 5 | import com.bsth.data.schedule.DayOfSchedule; |
| 5 | 6 | import com.google.common.collect.ArrayListMultimap; |
| ... | ... | @@ -11,6 +12,7 @@ import org.springframework.boot.CommandLineRunner; |
| 11 | 12 | import org.springframework.stereotype.Component; |
| 12 | 13 | |
| 13 | 14 | import java.util.*; |
| 15 | +import java.util.concurrent.TimeUnit; | |
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * |
| ... | ... | @@ -41,8 +43,8 @@ public class ArrivalData_GPS implements CommandLineRunner{ |
| 41 | 43 | |
| 42 | 44 | @Override |
| 43 | 45 | public void run(String... arg0) throws Exception { |
| 44 | - logger.info("ArrivalData_GPS,30,10"); | |
| 45 | - //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 10, TimeUnit.SECONDS); | |
| 46 | + logger.info("ArrivalData_GPS,30,06"); | |
| 47 | + Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 6, TimeUnit.SECONDS); | |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | @Component | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| 1 | 1 | package com.bsth.data.schedule; |
| 2 | 2 | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | -import java.util.ArrayList; | |
| 6 | -import java.util.Collection; | |
| 7 | -import java.util.Collections; | |
| 8 | -import java.util.HashMap; | |
| 9 | -import java.util.HashSet; | |
| 10 | -import java.util.Iterator; | |
| 11 | -import java.util.LinkedList; | |
| 12 | -import java.util.List; | |
| 13 | -import java.util.Map; | |
| 14 | -import java.util.Set; | |
| 15 | -import java.util.concurrent.TimeUnit; | |
| 16 | - | |
| 17 | -import com.bsth.data.schedule.thread.SubmitToTrafficManage; | |
| 18 | -import org.apache.commons.lang3.StringUtils; | |
| 19 | -import org.joda.time.DateTime; | |
| 20 | -import org.joda.time.format.DateTimeFormat; | |
| 21 | -import org.joda.time.format.DateTimeFormatter; | |
| 22 | -import org.slf4j.Logger; | |
| 23 | -import org.slf4j.LoggerFactory; | |
| 24 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 25 | -import org.springframework.boot.CommandLineRunner; | |
| 26 | -import org.springframework.stereotype.Component; | |
| 27 | - | |
| 28 | 3 | import com.alibaba.fastjson.JSON; |
| 29 | 4 | import com.alibaba.fastjson.JSONArray; |
| 30 | 5 | import com.bsth.Application; |
| ... | ... | @@ -34,6 +9,7 @@ import com.bsth.data.gpsdata.GpsRealData; |
| 34 | 9 | import com.bsth.data.schedule.thread.ScheduleLateThread; |
| 35 | 10 | import com.bsth.data.schedule.thread.SchedulePstThread; |
| 36 | 11 | import com.bsth.data.schedule.thread.ScheduleRefreshThread; |
| 12 | +import com.bsth.data.schedule.thread.SubmitToTrafficManage; | |
| 37 | 13 | import com.bsth.entity.realcontrol.LineConfig; |
| 38 | 14 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 39 | 15 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| ... | ... | @@ -44,6 +20,19 @@ import com.bsth.util.DateUtils; |
| 44 | 20 | import com.bsth.websocket.handler.SendUtils; |
| 45 | 21 | import com.google.common.collect.ArrayListMultimap; |
| 46 | 22 | import com.google.common.collect.TreeMultimap; |
| 23 | +import org.apache.commons.lang3.StringUtils; | |
| 24 | +import org.joda.time.format.DateTimeFormat; | |
| 25 | +import org.joda.time.format.DateTimeFormatter; | |
| 26 | +import org.slf4j.Logger; | |
| 27 | +import org.slf4j.LoggerFactory; | |
| 28 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 29 | +import org.springframework.boot.CommandLineRunner; | |
| 30 | +import org.springframework.stereotype.Component; | |
| 31 | + | |
| 32 | +import java.text.ParseException; | |
| 33 | +import java.text.SimpleDateFormat; | |
| 34 | +import java.util.*; | |
| 35 | +import java.util.concurrent.TimeUnit; | |
| 47 | 36 | |
| 48 | 37 | /** |
| 49 | 38 | * |
| ... | ... | @@ -142,7 +131,7 @@ public class DayOfSchedule implements CommandLineRunner { |
| 142 | 131 | diff+=(1000*60*60*24); |
| 143 | 132 | |
| 144 | 133 | logger.info(diff/1000/60 + "分钟之后提交到运管处"); |
| 145 | - //Application.mainServices.scheduleWithFixedDelay(submitToTrafficManage, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 134 | + Application.mainServices.scheduleWithFixedDelay(submitToTrafficManage, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 146 | 135 | } |
| 147 | 136 | |
| 148 | 137 | public Map<String, String> getCurrSchDate() { | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -29,8 +29,9 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 29 | 29 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs") |
| 30 | 30 | List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); |
| 31 | 31 | |
| 32 | + //把sum(addMileage) 替换为0 数据表去掉了 add_mileage 字段 | |
| 32 | 33 | @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl," |
| 33 | - + "sum(addMileage) as ksgl,count(jName) as bcs) from ScheduleRealInfo s where" | |
| 34 | + + " 0 as ksgl,count(jName) as bcs) from ScheduleRealInfo s where" | |
| 34 | 35 | + " s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh,jName") |
| 35 | 36 | List<Map<String, Object>> dailyInfo(String line,String date); |
| 36 | 37 | ... | ... |
src/main/java/com/bsth/service/realcontrol/RealMapService.java
| 1 | -package com.bsth.service.realcontrol; | |
| 2 | - | |
| 3 | -import java.util.Map; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * Created by panzhao on 2016/11/23. | |
| 7 | - */ | |
| 8 | -public interface RealMapService { | |
| 9 | - Map<String, Object> stationSpatialData(String idx); | |
| 10 | -} | |
| 1 | +package com.bsth.service.realcontrol; | |
| 2 | + | |
| 3 | +import java.util.Map; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by panzhao on 2016/11/23. | |
| 7 | + */ | |
| 8 | +public interface RealMapService { | |
| 9 | + Map<String, Object> stationSpatialData(String idx); | |
| 10 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/RealMapServiceImpl.java
| 1 | -package com.bsth.service.realcontrol.impl; | |
| 2 | - | |
| 3 | -import com.bsth.common.ResponseCode; | |
| 4 | -import com.bsth.controller.realcontrol.dto.StationSpatialData; | |
| 5 | -import com.bsth.service.realcontrol.RealMapService; | |
| 6 | -import com.google.common.base.Splitter; | |
| 7 | -import org.slf4j.Logger; | |
| 8 | -import org.slf4j.LoggerFactory; | |
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 11 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 12 | -import org.springframework.stereotype.Service; | |
| 13 | - | |
| 14 | -import java.util.HashMap; | |
| 15 | -import java.util.List; | |
| 16 | -import java.util.Map; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * Created by panzhao on 2016/11/23. | |
| 20 | - */ | |
| 21 | -@Service | |
| 22 | -public class RealMapServiceImpl implements RealMapService { | |
| 23 | - | |
| 24 | - @Autowired | |
| 25 | - JdbcTemplate jdbcTemplate; | |
| 26 | - | |
| 27 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - public Map<String, Object> stationSpatialData(String idx) { | |
| 31 | - Map<String, Object> rs = new HashMap(); | |
| 32 | - | |
| 33 | - try { | |
| 34 | - List<String> idArray = Splitter.on(",").splitToList(idx); | |
| 35 | - //拼接in语句 | |
| 36 | - String inStr = ""; | |
| 37 | - for (String code : idArray) { | |
| 38 | - inStr += (",'" + code+"'"); | |
| 39 | - } | |
| 40 | - inStr = " (" + inStr.substring(1) + ")"; | |
| 41 | - | |
| 42 | - String sql = "select R.LINE_CODE,R.STATION_NAME,R.STATION_CODE,R.STATION_MARK,R.DIRECTIONS,R.DISTANCES,R.TO_TIME, R.VERSIONS,S.G_LONX,S.G_LATY,S.RADIUS,S.SHAPES_TYPE,ST_AsText(S.G_POLYGON_GRID) as G_POLYGON_GRID, R.STATION_ROUTE_CODE from bsth_c_stationroute r inner join bsth_c_station s on r.station=s.id where r.line_code in "+inStr+" and r.destroy=0"; | |
| 43 | - | |
| 44 | - List<StationSpatialData> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(StationSpatialData.class)); | |
| 45 | - rs.put("status", ResponseCode.SUCCESS); | |
| 46 | - rs.put("list", list); | |
| 47 | - } catch (Exception e) { | |
| 48 | - logger.error("", e); | |
| 49 | - rs.put("status", ResponseCode.ERROR); | |
| 50 | - rs.put("msg", "查询站点空间数据出现异常!"); | |
| 51 | - } | |
| 52 | - | |
| 53 | - return rs; | |
| 54 | - } | |
| 55 | -} | |
| 1 | +package com.bsth.service.realcontrol.impl; | |
| 2 | + | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 4 | +import com.bsth.controller.realcontrol.dto.StationSpatialData; | |
| 5 | +import com.bsth.service.realcontrol.RealMapService; | |
| 6 | +import com.google.common.base.Splitter; | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 11 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | + | |
| 14 | +import java.util.HashMap; | |
| 15 | +import java.util.List; | |
| 16 | +import java.util.Map; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * Created by panzhao on 2016/11/23. | |
| 20 | + */ | |
| 21 | +@Service | |
| 22 | +public class RealMapServiceImpl implements RealMapService { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + JdbcTemplate jdbcTemplate; | |
| 26 | + | |
| 27 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + public Map<String, Object> stationSpatialData(String idx) { | |
| 31 | + Map<String, Object> rs = new HashMap(); | |
| 32 | + | |
| 33 | + try { | |
| 34 | + List<String> idArray = Splitter.on(",").splitToList(idx); | |
| 35 | + //拼接in语句 | |
| 36 | + String inStr = ""; | |
| 37 | + for (String code : idArray) { | |
| 38 | + inStr += (",'" + code+"'"); | |
| 39 | + } | |
| 40 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 41 | + | |
| 42 | + String sql = "select R.LINE_CODE,R.STATION_NAME,R.STATION_CODE,R.STATION_MARK,R.DIRECTIONS,R.DISTANCES,R.TO_TIME, R.VERSIONS,S.G_LONX,S.G_LATY,S.RADIUS,S.SHAPES_TYPE,ST_AsText(S.G_POLYGON_GRID) as G_POLYGON_GRID, R.STATION_ROUTE_CODE from bsth_c_stationroute r inner join bsth_c_station s on r.station=s.id where r.line_code in "+inStr+" and r.destroy=0"; | |
| 43 | + | |
| 44 | + List<StationSpatialData> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(StationSpatialData.class)); | |
| 45 | + rs.put("status", ResponseCode.SUCCESS); | |
| 46 | + rs.put("list", list); | |
| 47 | + } catch (Exception e) { | |
| 48 | + logger.error("", e); | |
| 49 | + rs.put("status", ResponseCode.ERROR); | |
| 50 | + rs.put("msg", "查询站点空间数据出现异常!"); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return rs; | |
| 54 | + } | |
| 55 | +} | ... | ... |