Commit 1726f97f365f96a79b7e2857ebabed74a01dfa55
1 parent
9c9f8a96
线路总数固定84
Showing
3 changed files
with
36 additions
and
9 deletions
src/main/java/com/bsth/server_rs/number/NumberService.java
| 1 | package com.bsth.server_rs.number; | 1 | package com.bsth.server_rs.number; |
| 2 | 2 | ||
| 3 | -import com.bsth.Application; | ||
| 4 | import com.bsth.server_rs.bigdata.BigdataService; | 3 | import com.bsth.server_rs.bigdata.BigdataService; |
| 5 | import com.bsth.server_rs.gps.GpsRestService; | 4 | import com.bsth.server_rs.gps.GpsRestService; |
| 6 | import com.bsth.server_rs.gps.entity.GpsEntity; | 5 | import com.bsth.server_rs.gps.entity.GpsEntity; |
| 6 | +import com.bsth.util.ConfigUtil; | ||
| 7 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | -import org.springframework.boot.CommandLineRunner; | ||
| 11 | import org.springframework.jdbc.core.JdbcTemplate; | 10 | import org.springframework.jdbc.core.JdbcTemplate; |
| 12 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
| 13 | import javax.ws.rs.GET; | 12 | import javax.ws.rs.GET; |
| @@ -16,12 +15,11 @@ import javax.ws.rs.Produces; | @@ -16,12 +15,11 @@ import javax.ws.rs.Produces; | ||
| 16 | import javax.ws.rs.core.MediaType; | 15 | import javax.ws.rs.core.MediaType; |
| 17 | import java.text.SimpleDateFormat; | 16 | import java.text.SimpleDateFormat; |
| 18 | import java.util.*; | 17 | import java.util.*; |
| 19 | -import java.util.concurrent.TimeUnit; | ||
| 20 | 18 | ||
| 21 | @Component | 19 | @Component |
| 22 | @Path("/number") | 20 | @Path("/number") |
| 23 | @Produces({MediaType.APPLICATION_JSON}) | 21 | @Produces({MediaType.APPLICATION_JSON}) |
| 24 | -public class NumberService implements CommandLineRunner{ | 22 | +public class NumberService { |
| 25 | 23 | ||
| 26 | @Autowired | 24 | @Autowired |
| 27 | GpsRestService gpsRestService; | 25 | GpsRestService gpsRestService; |
| @@ -41,7 +39,10 @@ public class NumberService implements CommandLineRunner{ | @@ -41,7 +39,10 @@ public class NumberService implements CommandLineRunner{ | ||
| 41 | @GET | 39 | @GET |
| 42 | @Path("/xlnum") | 40 | @Path("/xlnum") |
| 43 | public Map lxnum() { | 41 | public Map lxnum() { |
| 44 | - return XlThread.pule(); | 42 | + Map<String,Integer> map = new HashMap<>(); |
| 43 | + Integer xlnum = Integer.parseInt(ConfigUtil.getProperty("xlnum")); | ||
| 44 | + map.put("xlnum",xlnum); | ||
| 45 | + return map; | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | /** | 48 | /** |
| @@ -124,8 +125,8 @@ public class NumberService implements CommandLineRunner{ | @@ -124,8 +125,8 @@ public class NumberService implements CommandLineRunner{ | ||
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | 127 | ||
| 127 | - @Override | 128 | + /* @Override |
| 128 | public void run(String... strings) throws Exception { | 129 | public void run(String... strings) throws Exception { |
| 129 | Application.mainServices.scheduleWithFixedDelay(xlThread, 10, 60 * 60, TimeUnit.SECONDS);//查询线路总数 | 130 | Application.mainServices.scheduleWithFixedDelay(xlThread, 10, 60 * 60, TimeUnit.SECONDS);//查询线路总数 |
| 130 | - } | 131 | + }*/ |
| 131 | } | 132 | } |
src/main/java/com/bsth/util/ConfigUtil.java
| 1 | package com.bsth.util; | 1 | package com.bsth.util; |
| 2 | 2 | ||
| 3 | -public class ConfigUtil { | 3 | +import org.slf4j.Logger; |
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | + | ||
| 6 | +import java.io.IOException; | ||
| 7 | +import java.util.Properties; | ||
| 4 | 8 | ||
| 9 | +public class ConfigUtil { | ||
| 10 | + private final static Logger log = LoggerFactory.getLogger(ConfigUtil.class); | ||
| 11 | + private static Properties prop = new Properties(); | ||
| 5 | static Tools tools; | 12 | static Tools tools; |
| 6 | - | 13 | + |
| 7 | static{ | 14 | static{ |
| 8 | tools = new Tools("application.properties"); | 15 | tools = new Tools("application.properties"); |
| 9 | String active = tools.getValue("spring.profiles.active"); | 16 | String active = tools.getValue("spring.profiles.active"); |
| 10 | tools = new Tools("application-"+active+".properties"); | 17 | tools = new Tools("application-"+active+".properties"); |
| 18 | + tools = new Tools("application-"+active+".properties"); | ||
| 19 | + load(); | ||
| 11 | } | 20 | } |
| 12 | 21 | ||
| 13 | public static String get(String key){ | 22 | public static String get(String key){ |
| 14 | return tools.getValue(key); | 23 | return tools.getValue(key); |
| 15 | } | 24 | } |
| 25 | + /** | ||
| 26 | + * 从全局配置文件从获取数据 | ||
| 27 | + * @param key 键 | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + public static String getProperty(String key) { | ||
| 31 | + return prop.getProperty(key); | ||
| 32 | + } | ||
| 33 | + public static void load() { | ||
| 34 | + try { | ||
| 35 | + prop.load(ConfigUtil.class.getResourceAsStream("/xlnum.properties")); | ||
| 36 | + } catch (IOException e) { | ||
| 37 | + // TODO Auto-generated catch block | ||
| 38 | + log.error("加载lxnum.properties配置文件失败,请检查。。。", e); | ||
| 39 | + } | ||
| 40 | + } | ||
| 16 | } | 41 | } |
src/main/resources/xlnum.properties
0 → 100644