Commit 96920fe4f5b4a444cd425f06ebb3e69e3c75e5e0
1 parent
ab5fd6f0
update...
Showing
4 changed files
with
98 additions
and
2 deletions
src/main/java/com/bsth/server_rs/base_info/section/LD_SectionRestService.java
| @@ -2,6 +2,8 @@ package com.bsth.server_rs.base_info.section; | @@ -2,6 +2,8 @@ package com.bsth.server_rs.base_info.section; | ||
| 2 | 2 | ||
| 3 | import com.bsth.server_rs.base_info.section.buffer.LD_SectionBufferData; | 3 | import com.bsth.server_rs.base_info.section.buffer.LD_SectionBufferData; |
| 4 | import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; | 4 | import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; |
| 5 | +import com.bsth.server_rs.base_info.section.entity.RoadSpeed; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 5 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
| 6 | 8 | ||
| 7 | import javax.ws.rs.GET; | 9 | import javax.ws.rs.GET; |
| @@ -10,6 +12,7 @@ import javax.ws.rs.PathParam; | @@ -10,6 +12,7 @@ import javax.ws.rs.PathParam; | ||
| 10 | import javax.ws.rs.Produces; | 12 | import javax.ws.rs.Produces; |
| 11 | import javax.ws.rs.core.MediaType; | 13 | import javax.ws.rs.core.MediaType; |
| 12 | import java.util.Collection; | 14 | import java.util.Collection; |
| 15 | +import java.util.List; | ||
| 13 | import java.util.Map; | 16 | import java.util.Map; |
| 14 | 17 | ||
| 15 | /** | 18 | /** |
| @@ -21,9 +24,18 @@ import java.util.Map; | @@ -21,9 +24,18 @@ import java.util.Map; | ||
| 21 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | 24 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
| 22 | public class LD_SectionRestService { | 25 | public class LD_SectionRestService { |
| 23 | 26 | ||
| 27 | + @Autowired | ||
| 28 | + LD_SectionBufferData sectionBufferData; | ||
| 29 | + | ||
| 24 | @GET | 30 | @GET |
| 25 | @Path("/{company}") | 31 | @Path("/{company}") |
| 26 | public Map<String, Collection<LD_SectionRoute>> findByCompany(@PathParam("company") String company){ | 32 | public Map<String, Collection<LD_SectionRoute>> findByCompany(@PathParam("company") String company){ |
| 27 | - return LD_SectionBufferData.findRouteByCompany(company); | 33 | + return sectionBufferData.findRouteByCompany(company); |
| 34 | + } | ||
| 35 | + | ||
| 36 | + @GET | ||
| 37 | + @Path("/road_speed_config/{company}") | ||
| 38 | + public List<RoadSpeed> roadSpeedList(@PathParam("company") String company){ | ||
| 39 | + return sectionBufferData.roadSpeedList(company); | ||
| 28 | } | 40 | } |
| 29 | } | 41 | } |
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionBufferData.java
| @@ -5,10 +5,14 @@ import com.bsth.server_rs.base_info.line.Line; | @@ -5,10 +5,14 @@ import com.bsth.server_rs.base_info.line.Line; | ||
| 5 | import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | 5 | import com.bsth.server_rs.base_info.line.buffer.LineBufferData; |
| 6 | import com.bsth.server_rs.base_info.section.entity.LD_Section; | 6 | import com.bsth.server_rs.base_info.section.entity.LD_Section; |
| 7 | import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; | 7 | import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; |
| 8 | +import com.bsth.server_rs.base_info.section.entity.RoadSpeed; | ||
| 8 | import com.google.common.collect.ArrayListMultimap; | 9 | import com.google.common.collect.ArrayListMultimap; |
| 10 | +import org.slf4j.Logger; | ||
| 11 | +import org.slf4j.LoggerFactory; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.boot.CommandLineRunner; | 13 | import org.springframework.boot.CommandLineRunner; |
| 11 | import org.springframework.core.annotation.Order; | 14 | import org.springframework.core.annotation.Order; |
| 15 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 12 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
| 13 | 17 | ||
| 14 | import java.util.*; | 18 | import java.util.*; |
| @@ -26,9 +30,17 @@ public class LD_SectionBufferData implements CommandLineRunner { | @@ -26,9 +30,17 @@ public class LD_SectionBufferData implements CommandLineRunner { | ||
| 26 | private static List<LD_Section> data; | 30 | private static List<LD_Section> data; |
| 27 | private static Map<String, LD_Section> codeMap; | 31 | private static Map<String, LD_Section> codeMap; |
| 28 | 32 | ||
| 33 | + //路段限速缓存信息 | ||
| 34 | + private static List<RoadSpeed> roadSpeedList; | ||
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + JdbcTemplate jdbcTemplate; | ||
| 38 | + | ||
| 29 | @Autowired | 39 | @Autowired |
| 30 | LD_SectionRefreshThread ld_sectionRefreshThread; | 40 | LD_SectionRefreshThread ld_sectionRefreshThread; |
| 31 | 41 | ||
| 42 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 43 | + | ||
| 32 | /** | 44 | /** |
| 33 | 路由缓存 | 45 | 路由缓存 |
| 34 | 线路编码_上下行 ——> 路由集合 | 46 | 线路编码_上下行 ——> 路由集合 |
| @@ -58,6 +70,10 @@ public class LD_SectionBufferData implements CommandLineRunner { | @@ -58,6 +70,10 @@ public class LD_SectionBufferData implements CommandLineRunner { | ||
| 58 | codeMap = codeMapCopy; | 70 | codeMap = codeMapCopy; |
| 59 | } | 71 | } |
| 60 | 72 | ||
| 73 | + public static void putRoadSpeeds(List<RoadSpeed> list){ | ||
| 74 | + roadSpeedList = list; | ||
| 75 | + } | ||
| 76 | + | ||
| 61 | public static void replaceRoutes(List<LD_SectionRoute> list){ | 77 | public static void replaceRoutes(List<LD_SectionRoute> list){ |
| 62 | Collections.sort(list, new Comparator<LD_SectionRoute>() { | 78 | Collections.sort(list, new Comparator<LD_SectionRoute>() { |
| 63 | @Override | 79 | @Override |
| @@ -79,7 +95,7 @@ public class LD_SectionBufferData implements CommandLineRunner { | @@ -79,7 +95,7 @@ public class LD_SectionBufferData implements CommandLineRunner { | ||
| 79 | Application.mainServices.scheduleWithFixedDelay(ld_sectionRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); | 95 | Application.mainServices.scheduleWithFixedDelay(ld_sectionRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); |
| 80 | } | 96 | } |
| 81 | 97 | ||
| 82 | - public static Map<String, Collection<LD_SectionRoute>> findRouteByCompany(String company) { | 98 | + public Map<String, Collection<LD_SectionRoute>> findRouteByCompany(String company) { |
| 83 | List<Line> lines = LineBufferData.findByCompany(company); | 99 | List<Line> lines = LineBufferData.findByCompany(company); |
| 84 | 100 | ||
| 85 | ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create(); | 101 | ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create(); |
| @@ -103,4 +119,8 @@ public class LD_SectionBufferData implements CommandLineRunner { | @@ -103,4 +119,8 @@ public class LD_SectionBufferData implements CommandLineRunner { | ||
| 103 | } | 119 | } |
| 104 | return false; | 120 | return false; |
| 105 | } | 121 | } |
| 122 | + | ||
| 123 | + public List<RoadSpeed> roadSpeedList(String company) { | ||
| 124 | + return roadSpeedList; | ||
| 125 | + } | ||
| 106 | } | 126 | } |
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionRefreshThread.java
| @@ -2,6 +2,7 @@ package com.bsth.server_rs.base_info.section.buffer; | @@ -2,6 +2,7 @@ package com.bsth.server_rs.base_info.section.buffer; | ||
| 2 | 2 | ||
| 3 | import com.bsth.server_rs.base_info.section.entity.LD_Section; | 3 | import com.bsth.server_rs.base_info.section.entity.LD_Section; |
| 4 | import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; | 4 | import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; |
| 5 | +import com.bsth.server_rs.base_info.section.entity.RoadSpeed; | ||
| 5 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 6 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -45,6 +46,11 @@ public class LD_SectionRefreshThread extends Thread{ | @@ -45,6 +46,11 @@ public class LD_SectionRefreshThread extends Thread{ | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | LD_SectionBufferData.replaceRoutes(routeList); | 48 | LD_SectionBufferData.replaceRoutes(routeList); |
| 49 | + | ||
| 50 | + //查询路段限速信息 | ||
| 51 | + List<RoadSpeed> roadSpeedList = jdbcTemplate.query("select * from bsth_c_road_speed where is_start=0", BeanPropertyRowMapper.newInstance(RoadSpeed.class)); | ||
| 52 | + if(roadSpeedList.size() > 0) | ||
| 53 | + LD_SectionBufferData.putRoadSpeeds(roadSpeedList); | ||
| 48 | }catch (Exception e){ | 54 | }catch (Exception e){ |
| 49 | logger.error("", e); | 55 | logger.error("", e); |
| 50 | } | 56 | } |
src/main/java/com/bsth/server_rs/base_info/section/entity/RoadSpeed.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.section.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 路段限速 | ||
| 5 | + * Created by panzhao on 2017/11/12. | ||
| 6 | + */ | ||
| 7 | +public class RoadSpeed { | ||
| 8 | + | ||
| 9 | + private String name; | ||
| 10 | + | ||
| 11 | + private String gsectionVector; | ||
| 12 | + | ||
| 13 | + private Double speed; | ||
| 14 | + | ||
| 15 | + private String st; | ||
| 16 | + | ||
| 17 | + private String et; | ||
| 18 | + | ||
| 19 | + public String getName() { | ||
| 20 | + return name; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setName(String name) { | ||
| 24 | + this.name = name; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getGsectionVector() { | ||
| 28 | + return gsectionVector; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setGsectionVector(String gsectionVector) { | ||
| 32 | + this.gsectionVector = gsectionVector; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public Double getSpeed() { | ||
| 36 | + return speed; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setSpeed(Double speed) { | ||
| 40 | + this.speed = speed; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getSt() { | ||
| 44 | + return st; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setSt(String st) { | ||
| 48 | + this.st = st; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public String getEt() { | ||
| 52 | + return et; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setEt(String et) { | ||
| 56 | + this.et = et; | ||
| 57 | + } | ||
| 58 | +} |