Commit ccb15e34fd1de96775db80c37b2657082043d66f
1 parent
ab576aa9
1.
Showing
2 changed files
with
229 additions
and
229 deletions
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionBufferData.java
| 1 | -package com.bsth.server_rs.base_info.section.buffer; | ||
| 2 | - | ||
| 3 | -import com.bsth.Application; | ||
| 4 | -import com.bsth.server_rs.base_info.line.Line; | ||
| 5 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | ||
| 6 | -import com.bsth.server_rs.base_info.section.entity.LD_Section; | ||
| 7 | -import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; | ||
| 8 | -import com.bsth.server_rs.base_info.section.entity.RoadSpeed; | ||
| 9 | -import com.google.common.collect.ArrayListMultimap; | ||
| 10 | -import org.slf4j.Logger; | ||
| 11 | -import org.slf4j.LoggerFactory; | ||
| 12 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | -import org.springframework.boot.CommandLineRunner; | ||
| 14 | -import org.springframework.core.annotation.Order; | ||
| 15 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 16 | -import org.springframework.stereotype.Component; | ||
| 17 | - | ||
| 18 | -import java.util.*; | ||
| 19 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 20 | -import java.util.concurrent.TimeUnit; | ||
| 21 | - | ||
| 22 | -/** | ||
| 23 | - * 站点数据缓存(自更新) | ||
| 24 | - * Created by panzhao on 2017/3/27. | ||
| 25 | - */ | ||
| 26 | -@Component | ||
| 27 | -@Order(6) | ||
| 28 | -public class LD_SectionBufferData implements CommandLineRunner { | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - private static List<LD_Section> data; | ||
| 32 | - private static Map<String, LD_Section> codeMap; | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * 线路名称和路段集合映射 | ||
| 36 | - */ | ||
| 37 | - private static Map<String, List<LD_SectionRoute>> name2sections = new ConcurrentHashMap<>(); | ||
| 38 | - | ||
| 39 | - //路段限速缓存信息 | ||
| 40 | - private static List<RoadSpeed> roadSpeedList; | ||
| 41 | - | ||
| 42 | - @Autowired | ||
| 43 | - JdbcTemplate jdbcTemplate; | ||
| 44 | - | ||
| 45 | - @Autowired | ||
| 46 | - LD_SectionRefreshThread ld_sectionRefreshThread; | ||
| 47 | - | ||
| 48 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 49 | - | ||
| 50 | - /** | ||
| 51 | - 路由缓存 | ||
| 52 | - 线路编码_上下行 ——> 路由集合 | ||
| 53 | - */ | ||
| 54 | - private static ArrayListMultimap<String, LD_SectionRoute> routeListMap; | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - public static List<LD_Section> findAll(){ | ||
| 58 | - return data; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - public static Map<String, Collection<LD_SectionRoute>> findAllRoute(){ | ||
| 62 | - return routeListMap.asMap(); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - public static LD_Section findOne(String code){ | ||
| 66 | - return codeMap.get(code); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - public static void replaceAll(List<LD_Section> newData){ | ||
| 70 | - data = newData; | ||
| 71 | - Map<String, LD_Section> codeMapCopy = new HashMap<>(); | ||
| 72 | - for(LD_Section section : data){ | ||
| 73 | - codeMapCopy.put(section.getSectionCode(), section); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - codeMap = codeMapCopy; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - public static void putRoadSpeeds(List<RoadSpeed> list){ | ||
| 80 | - roadSpeedList = list; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - public static void replaceRoutes(List<LD_SectionRoute> list){ | ||
| 84 | - Collections.sort(list, new Comparator<LD_SectionRoute>() { | ||
| 85 | - @Override | ||
| 86 | - public int compare(LD_SectionRoute o1, LD_SectionRoute o2) { | ||
| 87 | - return o1.getSectionrouteCode().compareTo(o2.getSectionrouteCode()); | ||
| 88 | - } | ||
| 89 | - }); | ||
| 90 | - | ||
| 91 | - ArrayListMultimap<String, LD_SectionRoute> routeListMapCopy = ArrayListMultimap.create(); | ||
| 92 | - for(LD_SectionRoute sr : list){ | ||
| 93 | - routeListMapCopy.put(sr.getLineCode()+"_" + sr.getDirections(), sr); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - routeListMap = routeListMapCopy; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - @Override | ||
| 100 | - public void run(String... strings) throws Exception { | ||
| 101 | - Application.mainServices.scheduleWithFixedDelay(ld_sectionRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - public Map<String, Collection<LD_SectionRoute>> findRouteByCompany(String company) { | ||
| 105 | - List<Line> lines = LineBufferData.findByCompany(company); | ||
| 106 | - | ||
| 107 | - ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create(); | ||
| 108 | - | ||
| 109 | - | ||
| 110 | - Set<String> ks = routeListMap.keySet(); | ||
| 111 | - | ||
| 112 | - for(String k : ks){ | ||
| 113 | - if(include(lines, k)){ | ||
| 114 | - listMap.putAll(k, routeListMap.get(k)); | ||
| 115 | - } | ||
| 116 | - } | ||
| 117 | - return listMap.asMap(); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - private static boolean include(List<Line> lines, String k){ | ||
| 121 | - | ||
| 122 | - for(Line line : lines){ | ||
| 123 | - if(k.startsWith(line.getLineCode() + "_")) | ||
| 124 | - return true; | ||
| 125 | - } | ||
| 126 | - return false; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - public List<RoadSpeed> roadSpeedList(String company) { | ||
| 130 | - return roadSpeedList; | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - public Map<String, Collection<LD_SectionRoute>> findByLineCode(String lineCode) { | ||
| 134 | - | ||
| 135 | - ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create(); | ||
| 136 | - | ||
| 137 | - String k1 = lineCode + "_0"; | ||
| 138 | - String k2 = lineCode + "_1"; | ||
| 139 | - | ||
| 140 | - listMap.putAll(k1, routeListMap.get(k1)); | ||
| 141 | - listMap.putAll(k2, routeListMap.get(k2)); | ||
| 142 | - return listMap.asMap(); | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - public static void putLastedRoute(Map<String, List<LD_SectionRoute>> map) { | ||
| 146 | - name2sections = map; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - public List<LD_SectionRoute> findByLineName(String lineName) { | ||
| 150 | - return name2sections.get(lineName); | ||
| 151 | - } | ||
| 152 | -} | 1 | +package com.bsth.server_rs.base_info.section.buffer; |
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.server_rs.base_info.line.Line; | ||
| 5 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | ||
| 6 | +import com.bsth.server_rs.base_info.section.entity.LD_Section; | ||
| 7 | +import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; | ||
| 8 | +import com.bsth.server_rs.base_info.section.entity.RoadSpeed; | ||
| 9 | +import com.google.common.collect.ArrayListMultimap; | ||
| 10 | +import org.slf4j.Logger; | ||
| 11 | +import org.slf4j.LoggerFactory; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.boot.CommandLineRunner; | ||
| 14 | +import org.springframework.core.annotation.Order; | ||
| 15 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 16 | +import org.springframework.stereotype.Component; | ||
| 17 | + | ||
| 18 | +import java.util.*; | ||
| 19 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 20 | +import java.util.concurrent.TimeUnit; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * 站点数据缓存(自更新) | ||
| 24 | + * Created by panzhao on 2017/3/27. | ||
| 25 | + */ | ||
| 26 | +@Component | ||
| 27 | +@Order(6) | ||
| 28 | +public class LD_SectionBufferData implements CommandLineRunner { | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + private static List<LD_Section> data; | ||
| 32 | + private static Map<String, LD_Section> codeMap; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 线路名称和路段集合映射 | ||
| 36 | + */ | ||
| 37 | + private static Map<String, List<LD_SectionRoute>> name2sections = new ConcurrentHashMap<>(); | ||
| 38 | + | ||
| 39 | + //路段限速缓存信息 | ||
| 40 | + private static List<RoadSpeed> roadSpeedList = new ArrayList<>(); | ||
| 41 | + | ||
| 42 | + @Autowired | ||
| 43 | + JdbcTemplate jdbcTemplate; | ||
| 44 | + | ||
| 45 | + @Autowired | ||
| 46 | + LD_SectionRefreshThread ld_sectionRefreshThread; | ||
| 47 | + | ||
| 48 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + 路由缓存 | ||
| 52 | + 线路编码_上下行 ——> 路由集合 | ||
| 53 | + */ | ||
| 54 | + private static ArrayListMultimap<String, LD_SectionRoute> routeListMap; | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + public static List<LD_Section> findAll(){ | ||
| 58 | + return data; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public static Map<String, Collection<LD_SectionRoute>> findAllRoute(){ | ||
| 62 | + return routeListMap.asMap(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public static LD_Section findOne(String code){ | ||
| 66 | + return codeMap.get(code); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public static void replaceAll(List<LD_Section> newData){ | ||
| 70 | + data = newData; | ||
| 71 | + Map<String, LD_Section> codeMapCopy = new HashMap<>(); | ||
| 72 | + for(LD_Section section : data){ | ||
| 73 | + codeMapCopy.put(section.getSectionCode(), section); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + codeMap = codeMapCopy; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public static void putRoadSpeeds(List<RoadSpeed> list){ | ||
| 80 | + roadSpeedList = list; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public static void replaceRoutes(List<LD_SectionRoute> list){ | ||
| 84 | + Collections.sort(list, new Comparator<LD_SectionRoute>() { | ||
| 85 | + @Override | ||
| 86 | + public int compare(LD_SectionRoute o1, LD_SectionRoute o2) { | ||
| 87 | + return o1.getSectionrouteCode().compareTo(o2.getSectionrouteCode()); | ||
| 88 | + } | ||
| 89 | + }); | ||
| 90 | + | ||
| 91 | + ArrayListMultimap<String, LD_SectionRoute> routeListMapCopy = ArrayListMultimap.create(); | ||
| 92 | + for(LD_SectionRoute sr : list){ | ||
| 93 | + routeListMapCopy.put(sr.getLineCode()+"_" + sr.getDirections(), sr); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + routeListMap = routeListMapCopy; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Override | ||
| 100 | + public void run(String... strings) throws Exception { | ||
| 101 | + Application.mainServices.scheduleWithFixedDelay(ld_sectionRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public Map<String, Collection<LD_SectionRoute>> findRouteByCompany(String company) { | ||
| 105 | + List<Line> lines = LineBufferData.findByCompany(company); | ||
| 106 | + | ||
| 107 | + ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create(); | ||
| 108 | + | ||
| 109 | + | ||
| 110 | + Set<String> ks = routeListMap.keySet(); | ||
| 111 | + | ||
| 112 | + for(String k : ks){ | ||
| 113 | + if(include(lines, k)){ | ||
| 114 | + listMap.putAll(k, routeListMap.get(k)); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + return listMap.asMap(); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + private static boolean include(List<Line> lines, String k){ | ||
| 121 | + | ||
| 122 | + for(Line line : lines){ | ||
| 123 | + if(k.startsWith(line.getLineCode() + "_")) | ||
| 124 | + return true; | ||
| 125 | + } | ||
| 126 | + return false; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public List<RoadSpeed> roadSpeedList(String company) { | ||
| 130 | + return roadSpeedList; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public Map<String, Collection<LD_SectionRoute>> findByLineCode(String lineCode) { | ||
| 134 | + | ||
| 135 | + ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create(); | ||
| 136 | + | ||
| 137 | + String k1 = lineCode + "_0"; | ||
| 138 | + String k2 = lineCode + "_1"; | ||
| 139 | + | ||
| 140 | + listMap.putAll(k1, routeListMap.get(k1)); | ||
| 141 | + listMap.putAll(k2, routeListMap.get(k2)); | ||
| 142 | + return listMap.asMap(); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public static void putLastedRoute(Map<String, List<LD_SectionRoute>> map) { | ||
| 146 | + name2sections = map; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public List<LD_SectionRoute> findByLineName(String lineName) { | ||
| 150 | + return name2sections.get(lineName); | ||
| 151 | + } | ||
| 152 | +} |
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionRefreshThread.java
| 1 | -package com.bsth.server_rs.base_info.section.buffer; | ||
| 2 | - | ||
| 3 | -import com.bsth.server_rs.base_info.section.entity.LD_Section; | ||
| 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.slf4j.Logger; | ||
| 7 | -import org.slf4j.LoggerFactory; | ||
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 10 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | -import org.springframework.stereotype.Component; | ||
| 12 | - | ||
| 13 | -import java.util.ArrayList; | ||
| 14 | -import java.util.HashMap; | ||
| 15 | -import java.util.List; | ||
| 16 | -import java.util.Map; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * Created by panzhao on 2017/3/27. | ||
| 20 | - */ | ||
| 21 | -@Component | ||
| 22 | -public class LD_SectionRefreshThread extends Thread{ | ||
| 23 | - | ||
| 24 | - @Autowired | ||
| 25 | - JdbcTemplate jdbcTemplate; | ||
| 26 | - | ||
| 27 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 28 | - | ||
| 29 | - @Override | ||
| 30 | - public void run() { | ||
| 31 | - | ||
| 32 | - try { | ||
| 33 | - | ||
| 34 | - //路段信息 | ||
| 35 | - List<LD_Section> sectionList = jdbcTemplate.query("select section_code,section_name,section_type,ST_AsText(gsection_vector) as gsection_vector,ST_AsText(bsection_vector) as bsection_vector,croses_road,versions from bsth_c_section ", | ||
| 36 | - BeanPropertyRowMapper.newInstance(LD_Section.class)); | ||
| 37 | - | ||
| 38 | - if(sectionList == null || sectionList.size() == 0) | ||
| 39 | - return; | ||
| 40 | - | ||
| 41 | - LD_SectionBufferData.replaceAll(sectionList); | ||
| 42 | - | ||
| 43 | - //路段路由信息 | ||
| 44 | - List<LD_SectionRoute> routeList = jdbcTemplate.query("select line_code,section_code,directions,sectionroute_code,versions from bsth_c_sectionroute where destroy=0", | ||
| 45 | - BeanPropertyRowMapper.newInstance(LD_SectionRoute.class)); | ||
| 46 | - | ||
| 47 | - for(LD_SectionRoute sr : routeList){ | ||
| 48 | - sr.setSection(LD_SectionBufferData.findOne(sr.getSectionCode())); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - LD_SectionBufferData.replaceRoutes(routeList); | ||
| 52 | - | ||
| 53 | - //查询路段限速信息 | ||
| 54 | - List<RoadSpeed> roadSpeedList = jdbcTemplate.query("select id,name,ST_AsText(g_road_vector) as g_road_vector,speed,speed_start_date,speed_end_date,line,is_start,create_date,update_date from bsth_c_road_speed where is_start=0", BeanPropertyRowMapper.newInstance(RoadSpeed.class)); | ||
| 55 | - if(roadSpeedList.size() > 0) | ||
| 56 | - LD_SectionBufferData.putRoadSpeeds(roadSpeedList); | ||
| 57 | - | ||
| 58 | - //查询最新版本路段信息 | ||
| 59 | - List<LD_SectionRoute> sectionRoutes = jdbcTemplate.query("select b.line_name,a.line_code,a.section_code,a.directions,a.sectionroute_code,a.versions from (select l.name line_name,l.line_code line_code,max(versions) versions from bsth_c_line l left join bsth_c_line_versions v on l.line_code = v.line_code where l.destroy = 0 group by l.name,l.line_code) b left join bsth_c_ls_sectionroute a on a.line_code = b.line_code and a.versions = b.versions where a.destroy = 0 order by a.line_code,a.directions,a.sectionroute_code", BeanPropertyRowMapper.newInstance(LD_SectionRoute.class)); | ||
| 60 | - Map<String, List<LD_SectionRoute>> name2sections = new HashMap<>(); | ||
| 61 | - List<LD_SectionRoute> routes = null; | ||
| 62 | - String lastedLineName = ""; | ||
| 63 | - for (LD_SectionRoute sr : sectionRoutes) { | ||
| 64 | - if ("".equals(lastedLineName) || !lastedLineName.equals(sr.getLineName())) { | ||
| 65 | - name2sections.put(lastedLineName, routes); | ||
| 66 | - lastedLineName = sr.getLineName(); | ||
| 67 | - routes = new ArrayList<>(); | ||
| 68 | - } | ||
| 69 | - sr.setSection(LD_SectionBufferData.findOne(sr.getSectionCode())); | ||
| 70 | - routes.add(sr); | ||
| 71 | - } | ||
| 72 | - LD_SectionBufferData.putLastedRoute(name2sections); | ||
| 73 | - }catch (Exception e){ | ||
| 74 | - logger.error("", e); | ||
| 75 | - } | ||
| 76 | - } | ||
| 77 | -} | 1 | +package com.bsth.server_rs.base_info.section.buffer; |
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.section.entity.LD_Section; | ||
| 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.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 10 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | +import org.springframework.stereotype.Component; | ||
| 12 | + | ||
| 13 | +import java.util.ArrayList; | ||
| 14 | +import java.util.HashMap; | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Created by panzhao on 2017/3/27. | ||
| 20 | + */ | ||
| 21 | +@Component | ||
| 22 | +public class LD_SectionRefreshThread extends Thread{ | ||
| 23 | + | ||
| 24 | + @Autowired | ||
| 25 | + JdbcTemplate jdbcTemplate; | ||
| 26 | + | ||
| 27 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public void run() { | ||
| 31 | + | ||
| 32 | + try { | ||
| 33 | + | ||
| 34 | + //路段信息 | ||
| 35 | + List<LD_Section> sectionList = jdbcTemplate.query("select section_code,section_name,section_type,ST_AsText(gsection_vector) as gsection_vector,ST_AsText(bsection_vector) as bsection_vector,croses_road,versions from bsth_c_section ", | ||
| 36 | + BeanPropertyRowMapper.newInstance(LD_Section.class)); | ||
| 37 | + | ||
| 38 | + if(sectionList == null || sectionList.size() == 0) | ||
| 39 | + return; | ||
| 40 | + | ||
| 41 | + LD_SectionBufferData.replaceAll(sectionList); | ||
| 42 | + | ||
| 43 | + //路段路由信息 | ||
| 44 | + List<LD_SectionRoute> routeList = jdbcTemplate.query("select line_code,section_code,directions,sectionroute_code,versions from bsth_c_sectionroute where destroy=0", | ||
| 45 | + BeanPropertyRowMapper.newInstance(LD_SectionRoute.class)); | ||
| 46 | + | ||
| 47 | + for(LD_SectionRoute sr : routeList){ | ||
| 48 | + sr.setSection(LD_SectionBufferData.findOne(sr.getSectionCode())); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + LD_SectionBufferData.replaceRoutes(routeList); | ||
| 52 | + | ||
| 53 | + //查询路段限速信息 | ||
| 54 | + //List<RoadSpeed> roadSpeedList = jdbcTemplate.query("select id,name,ST_AsText(g_road_vector) as g_road_vector,speed,speed_start_date,speed_end_date,line,is_start,create_date,update_date from bsth_c_road_speed where is_start=0", BeanPropertyRowMapper.newInstance(RoadSpeed.class)); | ||
| 55 | + //if(roadSpeedList.size() > 0) | ||
| 56 | + // LD_SectionBufferData.putRoadSpeeds(roadSpeedList); | ||
| 57 | + | ||
| 58 | + //查询最新版本路段信息 | ||
| 59 | + List<LD_SectionRoute> sectionRoutes = jdbcTemplate.query("select b.line_name,a.line_code,a.section_code,a.directions,a.sectionroute_code,a.versions from (select l.name line_name,l.line_code line_code,max(versions) versions from bsth_c_line l left join bsth_c_line_versions v on l.line_code = v.line_code where l.destroy = 0 group by l.name,l.line_code) b left join bsth_c_ls_sectionroute a on a.line_code = b.line_code and a.versions = b.versions where a.destroy = 0 order by a.line_code,a.directions,a.sectionroute_code", BeanPropertyRowMapper.newInstance(LD_SectionRoute.class)); | ||
| 60 | + Map<String, List<LD_SectionRoute>> name2sections = new HashMap<>(); | ||
| 61 | + List<LD_SectionRoute> routes = null; | ||
| 62 | + String lastedLineName = ""; | ||
| 63 | + for (LD_SectionRoute sr : sectionRoutes) { | ||
| 64 | + if ("".equals(lastedLineName) || !lastedLineName.equals(sr.getLineName())) { | ||
| 65 | + name2sections.put(lastedLineName, routes); | ||
| 66 | + lastedLineName = sr.getLineName(); | ||
| 67 | + routes = new ArrayList<>(); | ||
| 68 | + } | ||
| 69 | + sr.setSection(LD_SectionBufferData.findOne(sr.getSectionCode())); | ||
| 70 | + routes.add(sr); | ||
| 71 | + } | ||
| 72 | + LD_SectionBufferData.putLastedRoute(name2sections); | ||
| 73 | + }catch (Exception e){ | ||
| 74 | + logger.error("", e); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | +} |