Commit 1726f97f365f96a79b7e2857ebabed74a01dfa55

Authored by ljq
1 parent 9c9f8a96

线路总数固定84

src/main/java/com/bsth/server_rs/number/NumberService.java
1 1 package com.bsth.server_rs.number;
2 2  
3   -import com.bsth.Application;
4 3 import com.bsth.server_rs.bigdata.BigdataService;
5 4 import com.bsth.server_rs.gps.GpsRestService;
6 5 import com.bsth.server_rs.gps.entity.GpsEntity;
  6 +import com.bsth.util.ConfigUtil;
7 7 import org.slf4j.Logger;
8 8 import org.slf4j.LoggerFactory;
9 9 import org.springframework.beans.factory.annotation.Autowired;
10   -import org.springframework.boot.CommandLineRunner;
11 10 import org.springframework.jdbc.core.JdbcTemplate;
12 11 import org.springframework.stereotype.Component;
13 12 import javax.ws.rs.GET;
... ... @@ -16,12 +15,11 @@ import javax.ws.rs.Produces;
16 15 import javax.ws.rs.core.MediaType;
17 16 import java.text.SimpleDateFormat;
18 17 import java.util.*;
19   -import java.util.concurrent.TimeUnit;
20 18  
21 19 @Component
22 20 @Path("/number")
23 21 @Produces({MediaType.APPLICATION_JSON})
24   -public class NumberService implements CommandLineRunner{
  22 +public class NumberService {
25 23  
26 24 @Autowired
27 25 GpsRestService gpsRestService;
... ... @@ -41,7 +39,10 @@ public class NumberService implements CommandLineRunner{
41 39 @GET
42 40 @Path("/xlnum")
43 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 125 }
125 126  
126 127  
127   - @Override
  128 + /* @Override
128 129 public void run(String... strings) throws Exception {
129 130 Application.mainServices.scheduleWithFixedDelay(xlThread, 10, 60 * 60, TimeUnit.SECONDS);//查询线路总数
130   - }
  131 + }*/
131 132 }
... ...
src/main/java/com/bsth/util/ConfigUtil.java
1 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 12 static Tools tools;
6   -
  13 +
7 14 static{
8 15 tools = new Tools("application.properties");
9 16 String active = tools.getValue("spring.profiles.active");
10 17 tools = new Tools("application-"+active+".properties");
  18 + tools = new Tools("application-"+active+".properties");
  19 + load();
11 20 }
12 21  
13 22 public static String get(String key){
14 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
  1 +xlnum= 84
0 2 \ No newline at end of file
... ...