Commit 9d8e0540e66577484d22bed9cc75f98c8f18350b
1 parent
5308e80a
update...
Showing
2 changed files
with
19 additions
and
6 deletions
src/main/java/com/bsth/XDApplication.java
| @@ -86,9 +86,15 @@ public class XDApplication implements CommandLineRunner { | @@ -86,9 +86,15 @@ public class XDApplication implements CommandLineRunner { | ||
| 86 | public void devInit(){ | 86 | public void devInit(){ |
| 87 | ScheduledExecutorService sexec = Application.mainServices; | 87 | ScheduledExecutorService sexec = Application.mainServices; |
| 88 | //抓取GPS数据 | 88 | //抓取GPS数据 |
| 89 | - //sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS); | 89 | + gpsDataLoader.setFlag(-1); |
| 90 | + sexec.scheduleWithFixedDelay(gpsDataLoader, 30, 2, TimeUnit.SECONDS); | ||
| 90 | //实际排班更新线程 | 91 | //实际排班更新线程 |
| 91 | - //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); | 92 | + sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); |
| 93 | + //实际排班延迟入库线程 | ||
| 94 | + sexec.scheduleWithFixedDelay(schedulePstThread, 60, 30, TimeUnit.SECONDS); | ||
| 95 | + | ||
| 96 | + //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | ||
| 97 | + sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS); | ||
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | public void prodInit(){ | 100 | public void prodInit(){ |
| @@ -114,8 +120,7 @@ public class XDApplication implements CommandLineRunner { | @@ -114,8 +120,7 @@ public class XDApplication implements CommandLineRunner { | ||
| 114 | //计算油、公里加注 | 120 | //计算油、公里加注 |
| 115 | sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | 121 | sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); |
| 116 | 122 | ||
| 117 | - | ||
| 118 | //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | 123 | //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) |
| 119 | - sexec.scheduleWithFixedDelay(threadMonotor, 120, 60, TimeUnit.SECONDS); | 124 | + sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS); |
| 120 | } | 125 | } |
| 121 | } | 126 | } |
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java
| @@ -45,9 +45,17 @@ public class GpsDataLoaderThread extends Thread { | @@ -45,9 +45,17 @@ public class GpsDataLoaderThread extends Thread { | ||
| 45 | // GPS客户端内存数据接口 | 45 | // GPS客户端内存数据接口 |
| 46 | private static String clientUrl; | 46 | private static String clientUrl; |
| 47 | 47 | ||
| 48 | - //0:从客户端内存获取 -1:从网关获取 | 48 | + //0:从GPS客户端内存获取 -1:从网关获取 |
| 49 | private static int flag = 0; | 49 | private static int flag = 0; |
| 50 | 50 | ||
| 51 | + public void setFlag(int v){ | ||
| 52 | + flag = v; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public int getFlag(int v){ | ||
| 56 | + return flag; | ||
| 57 | + } | ||
| 58 | + | ||
| 51 | @Autowired | 59 | @Autowired |
| 52 | GpsRealData gpsRealData; | 60 | GpsRealData gpsRealData; |
| 53 | 61 | ||
| @@ -151,7 +159,7 @@ public class GpsDataLoaderThread extends Thread { | @@ -151,7 +159,7 @@ public class GpsDataLoaderThread extends Thread { | ||
| 151 | //超时时间 | 159 | //超时时间 |
| 152 | RequestConfig requestConfig = RequestConfig.custom() | 160 | RequestConfig requestConfig = RequestConfig.custom() |
| 153 | .setConnectTimeout(2000).setConnectionRequestTimeout(1000) | 161 | .setConnectTimeout(2000).setConnectionRequestTimeout(1000) |
| 154 | - .setSocketTimeout(2000).build(); | 162 | + .setSocketTimeout(3000).build(); |
| 155 | get.setConfig(requestConfig); | 163 | get.setConfig(requestConfig); |
| 156 | 164 | ||
| 157 | response = httpClient.execute(get); | 165 | response = httpClient.execute(get); |