Commit 1c831cc354c43a7619d5ca4fb49c2983fc36c1c2

Authored by 王通
1 parent 7f11e647

1.提供给电科已撤销线路,新加线路撤销时间字段

src/main/java/com/bsth/server_rs/base_info/line/Line.java
1   -package com.bsth.server_rs.base_info.line;
2   -
3   -import com.bsth.server_rs.adapter.DateTimeAdapter;
4   -
5   -import javax.xml.bind.annotation.XmlRootElement;
6   -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
7   -import java.io.Serializable;
8   -import java.util.Date;
9   -
10   -
11   -/**
12   - * @ClassName: Line(线路实体类)
13   - * @Description: TODO(线路)
14   - * @Author bsth@lq
15   - * @Date 2016-4-11 16:06:17
16   - * @Version 公交调度系统BS版 0.1
17   - */
18   -@XmlRootElement
19   -public class Line implements Serializable {
20   -
21   -
22   - /**线路名称 varchar length(50) 不能为空*/
23   - private String name;
24   -
25   - /** 线路编码 varchar length(50) 不能为空*/
26   - private String lineCode;
27   -
28   - /** 起始站名称*/
29   - private String startStationName;
30   -
31   - /** 终点站名称*/
32   - private String endStationName;
33   -
34   - /** 起始站首班车时间 00:00 */
35   - private String startStationFirstTime;
36   -
37   - /** 起始站末班车时间 00:00 */
38   - private String startStationEndTime;
39   -
40   - /** 终点站首班时间 00:00 */
41   - private String endStationFirstTime;
42   -
43   - /** 终点站末班时间 00:00 */
44   - private String endStationEndTime;
45   -
46   - /** 所属公司 */
47   - private String company;
48   -
49   - /**
50   - * 所属公司名称
51   - */
52   - private String companyName;
53   -
54   - /** 分公司 */
55   - private String brancheCompany;
56   -
57   - /** 性质(线路类型) */
58   - private String nature;
59   -
60   - /**线路等级 */
61   - private String level;
62   -
63   - /**是否撤销 <1:是;0:否> */
64   - private Integer destroy;
65   -
66   - /** 是否夜宵线 <1:是;0:否> */
67   - private Integer supperLine;
68   -
69   - /** 设备线路编码 */
70   - private String eqLinecode;
71   -
72   - /**
73   - * 创建日期 timestamp
74   - */
75   - private Date createDate;
76   -
77   - //-------------- 标准信息 -----------
78   - /** 标准总里程 */
79   - private Double totalMileage;
80   - /** 早高峰大间隔(分钟) */
81   - private Double earlyIntervalLg;
82   -
83   - /** 晚高峰大间隔(分钟) */
84   - private Double lateIntervalLg;
85   -
86   - /** 平时大间隔(分钟) */
87   - private Double intervalLg;
88   -
89   - /** 限速(平时) */
90   - private Double speedLimit;
91   -
92   - /** 滞站 */
93   - private Integer lagStation;
94   -
95   - /** 越站 */
96   - private Integer skip;
97   -
98   - /** 超速 */
99   - private Integer speeding;
100   -
101   - /** 串线 */
102   - private Integer crossedLine;
103   -
104   - /** 越界 */
105   - private Integer overflights;
106   -
107   - /**
108   - * 上海市线路编码
109   - */
110   - private String shanghaiLinecode;
111   -
112   - // 环线或双向
113   - private int linePlayType;
114   - // 区内/外
115   - private int region;
116   -
117   - /**
118   - * 运管处和app上线标识
119   - * @return
120   - */
121   - private Integer inUse;
122   -
123   - public String getName() {
124   - return name;
125   - }
126   -
127   - public void setName(String name) {
128   - this.name = name;
129   - }
130   -
131   - public String getLineCode() {
132   - return lineCode;
133   - }
134   -
135   - public void setLineCode(String lineCode) {
136   - this.lineCode = lineCode;
137   - }
138   -
139   - public String getStartStationName() {
140   - return startStationName;
141   - }
142   -
143   - public void setStartStationName(String startStationName) {
144   - this.startStationName = startStationName;
145   - }
146   -
147   - public String getEndStationName() {
148   - return endStationName;
149   - }
150   -
151   - public void setEndStationName(String endStationName) {
152   - this.endStationName = endStationName;
153   - }
154   -
155   - public String getStartStationFirstTime() {
156   - return startStationFirstTime;
157   - }
158   -
159   - public void setStartStationFirstTime(String startStationFirstTime) {
160   - this.startStationFirstTime = startStationFirstTime;
161   - }
162   -
163   - public String getStartStationEndTime() {
164   - return startStationEndTime;
165   - }
166   -
167   - public void setStartStationEndTime(String startStationEndTime) {
168   - this.startStationEndTime = startStationEndTime;
169   - }
170   -
171   - public String getEndStationFirstTime() {
172   - return endStationFirstTime;
173   - }
174   -
175   - public void setEndStationFirstTime(String endStationFirstTime) {
176   - this.endStationFirstTime = endStationFirstTime;
177   - }
178   -
179   - public String getEndStationEndTime() {
180   - return endStationEndTime;
181   - }
182   -
183   - public void setEndStationEndTime(String endStationEndTime) {
184   - this.endStationEndTime = endStationEndTime;
185   - }
186   -
187   - public String getCompany() {
188   - return company;
189   - }
190   -
191   - public void setCompany(String company) {
192   - this.company = company;
193   - }
194   -
195   - public String getCompanyName() {
196   - return companyName;
197   - }
198   -
199   - public void setCompanyName(String companyName) {
200   - this.companyName = companyName;
201   - }
202   -
203   - public String getBrancheCompany() {
204   - return brancheCompany;
205   - }
206   -
207   - public void setBrancheCompany(String brancheCompany) {
208   - this.brancheCompany = brancheCompany;
209   - }
210   -
211   - public String getNature() {
212   - return nature;
213   - }
214   -
215   - public void setNature(String nature) {
216   - this.nature = nature;
217   - }
218   -
219   - public String getLevel() {
220   - return level;
221   - }
222   -
223   - public void setLevel(String level) {
224   - this.level = level;
225   - }
226   -
227   - public Integer getDestroy() {
228   - return destroy;
229   - }
230   -
231   - public void setDestroy(Integer destroy) {
232   - this.destroy = destroy;
233   - }
234   -
235   - public Integer getSupperLine() {
236   - return supperLine;
237   - }
238   -
239   - public void setSupperLine(Integer supperLine) {
240   - this.supperLine = supperLine;
241   - }
242   -
243   - public String getEqLinecode() {
244   - return eqLinecode;
245   - }
246   -
247   - public void setEqLinecode(String eqLinecode) {
248   - this.eqLinecode = eqLinecode;
249   - }
250   -
251   - @XmlJavaTypeAdapter(DateTimeAdapter.class)
252   - public Date getCreateDate() {
253   - return createDate;
254   - }
255   -
256   - public void setCreateDate(Date createDate) {
257   - this.createDate = createDate;
258   - }
259   -
260   - public Double getTotalMileage() {
261   - return totalMileage;
262   - }
263   -
264   - public void setTotalMileage(Double totalMileage) {
265   - this.totalMileage = totalMileage;
266   - }
267   -
268   - public Double getEarlyIntervalLg() {
269   - return earlyIntervalLg;
270   - }
271   -
272   - public void setEarlyIntervalLg(Double earlyIntervalLg) {
273   - this.earlyIntervalLg = earlyIntervalLg;
274   - }
275   -
276   - public Double getLateIntervalLg() {
277   - return lateIntervalLg;
278   - }
279   -
280   - public void setLateIntervalLg(Double lateIntervalLg) {
281   - this.lateIntervalLg = lateIntervalLg;
282   - }
283   -
284   - public Double getIntervalLg() {
285   - return intervalLg;
286   - }
287   -
288   - public void setIntervalLg(Double intervalLg) {
289   - this.intervalLg = intervalLg;
290   - }
291   -
292   - public Double getSpeedLimit() {
293   - return speedLimit;
294   - }
295   -
296   - public void setSpeedLimit(Double speedLimit) {
297   - this.speedLimit = speedLimit;
298   - }
299   -
300   - public Integer getLagStation() {
301   - return lagStation;
302   - }
303   -
304   - public void setLagStation(Integer lagStation) {
305   - this.lagStation = lagStation;
306   - }
307   -
308   - public Integer getSkip() {
309   - return skip;
310   - }
311   -
312   - public void setSkip(Integer skip) {
313   - this.skip = skip;
314   - }
315   -
316   - public Integer getSpeeding() {
317   - return speeding;
318   - }
319   -
320   - public void setSpeeding(Integer speeding) {
321   - this.speeding = speeding;
322   - }
323   -
324   - public Integer getCrossedLine() {
325   - return crossedLine;
326   - }
327   -
328   - public void setCrossedLine(Integer crossedLine) {
329   - this.crossedLine = crossedLine;
330   - }
331   -
332   - public Integer getOverflights() {
333   - return overflights;
334   - }
335   -
336   - public void setOverflights(Integer overflights) {
337   - this.overflights = overflights;
338   - }
339   -
340   - public String getShanghaiLinecode() {
341   - return shanghaiLinecode;
342   - }
343   -
344   - public void setShanghaiLinecode(String shanghaiLinecode) {
345   - this.shanghaiLinecode = shanghaiLinecode;
346   - }
347   -
348   - public int getLinePlayType() {
349   - return linePlayType;
350   - }
351   -
352   - public void setLinePlayType(int linePlayType) {
353   - this.linePlayType = linePlayType;
354   - }
355   -
356   - public int getRegion() {
357   - return region;
358   - }
359   -
360   - public void setRegion(int region) {
361   - this.region = region;
362   - }
363   -
364   - public Integer getInUse() {
365   - return inUse;
366   - }
367   -
368   - public void setInUse(Integer inUse) {
369   - this.inUse = inUse;
370   - }
371   -}
  1 +package com.bsth.server_rs.base_info.line;
  2 +
  3 +import com.bsth.server_rs.adapter.DateTimeAdapter;
  4 +
  5 +import javax.xml.bind.annotation.XmlRootElement;
  6 +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +
  10 +
  11 +/**
  12 + * @ClassName: Line(线路实体类)
  13 + * @Description: TODO(线路)
  14 + * @Author bsth@lq
  15 + * @Date 2016-4-11 16:06:17
  16 + * @Version 公交调度系统BS版 0.1
  17 + */
  18 +@XmlRootElement
  19 +public class Line implements Serializable {
  20 +
  21 +
  22 + /**线路名称 varchar length(50) 不能为空*/
  23 + private String name;
  24 +
  25 + /** 线路编码 varchar length(50) 不能为空*/
  26 + private String lineCode;
  27 +
  28 + /** 起始站名称*/
  29 + private String startStationName;
  30 +
  31 + /** 终点站名称*/
  32 + private String endStationName;
  33 +
  34 + /** 起始站首班车时间 00:00 */
  35 + private String startStationFirstTime;
  36 +
  37 + /** 起始站末班车时间 00:00 */
  38 + private String startStationEndTime;
  39 +
  40 + /** 终点站首班时间 00:00 */
  41 + private String endStationFirstTime;
  42 +
  43 + /** 终点站末班时间 00:00 */
  44 + private String endStationEndTime;
  45 +
  46 + /** 所属公司 */
  47 + private String company;
  48 +
  49 + /**
  50 + * 所属公司名称
  51 + */
  52 + private String companyName;
  53 +
  54 + /** 分公司 */
  55 + private String brancheCompany;
  56 +
  57 + /** 性质(线路类型) */
  58 + private String nature;
  59 +
  60 + /**线路等级 */
  61 + private String level;
  62 +
  63 + /**是否撤销 <1:是;0:否> */
  64 + private Integer destroy;
  65 +
  66 + /** 是否夜宵线 <1:是;0:否> */
  67 + private Integer supperLine;
  68 +
  69 + /** 设备线路编码 */
  70 + private String eqLinecode;
  71 +
  72 + /**
  73 + * 创建日期 timestamp
  74 + */
  75 + private Date createDate;
  76 +
  77 + //-------------- 标准信息 -----------
  78 + /** 标准总里程 */
  79 + private Double totalMileage;
  80 + /** 早高峰大间隔(分钟) */
  81 + private Double earlyIntervalLg;
  82 +
  83 + /** 晚高峰大间隔(分钟) */
  84 + private Double lateIntervalLg;
  85 +
  86 + /** 平时大间隔(分钟) */
  87 + private Double intervalLg;
  88 +
  89 + /** 限速(平时) */
  90 + private Double speedLimit;
  91 +
  92 + /** 滞站 */
  93 + private Integer lagStation;
  94 +
  95 + /** 越站 */
  96 + private Integer skip;
  97 +
  98 + /** 超速 */
  99 + private Integer speeding;
  100 +
  101 + /** 串线 */
  102 + private Integer crossedLine;
  103 +
  104 + /** 越界 */
  105 + private Integer overflights;
  106 +
  107 + /**
  108 + * 上海市线路编码
  109 + */
  110 + private String shanghaiLinecode;
  111 +
  112 + // 环线或双向
  113 + private int linePlayType;
  114 + // 区内/外
  115 + private int region;
  116 +
  117 + /**
  118 + * 运管处和app上线标识
  119 + * @return
  120 + */
  121 + private Integer inUse;
  122 +
  123 + /**
  124 + *
  125 + */
  126 + private Date revokeDate;
  127 +
  128 + public String getName() {
  129 + return name;
  130 + }
  131 +
  132 + public void setName(String name) {
  133 + this.name = name;
  134 + }
  135 +
  136 + public String getLineCode() {
  137 + return lineCode;
  138 + }
  139 +
  140 + public void setLineCode(String lineCode) {
  141 + this.lineCode = lineCode;
  142 + }
  143 +
  144 + public String getStartStationName() {
  145 + return startStationName;
  146 + }
  147 +
  148 + public void setStartStationName(String startStationName) {
  149 + this.startStationName = startStationName;
  150 + }
  151 +
  152 + public String getEndStationName() {
  153 + return endStationName;
  154 + }
  155 +
  156 + public void setEndStationName(String endStationName) {
  157 + this.endStationName = endStationName;
  158 + }
  159 +
  160 + public String getStartStationFirstTime() {
  161 + return startStationFirstTime;
  162 + }
  163 +
  164 + public void setStartStationFirstTime(String startStationFirstTime) {
  165 + this.startStationFirstTime = startStationFirstTime;
  166 + }
  167 +
  168 + public String getStartStationEndTime() {
  169 + return startStationEndTime;
  170 + }
  171 +
  172 + public void setStartStationEndTime(String startStationEndTime) {
  173 + this.startStationEndTime = startStationEndTime;
  174 + }
  175 +
  176 + public String getEndStationFirstTime() {
  177 + return endStationFirstTime;
  178 + }
  179 +
  180 + public void setEndStationFirstTime(String endStationFirstTime) {
  181 + this.endStationFirstTime = endStationFirstTime;
  182 + }
  183 +
  184 + public String getEndStationEndTime() {
  185 + return endStationEndTime;
  186 + }
  187 +
  188 + public void setEndStationEndTime(String endStationEndTime) {
  189 + this.endStationEndTime = endStationEndTime;
  190 + }
  191 +
  192 + public String getCompany() {
  193 + return company;
  194 + }
  195 +
  196 + public void setCompany(String company) {
  197 + this.company = company;
  198 + }
  199 +
  200 + public String getCompanyName() {
  201 + return companyName;
  202 + }
  203 +
  204 + public void setCompanyName(String companyName) {
  205 + this.companyName = companyName;
  206 + }
  207 +
  208 + public String getBrancheCompany() {
  209 + return brancheCompany;
  210 + }
  211 +
  212 + public void setBrancheCompany(String brancheCompany) {
  213 + this.brancheCompany = brancheCompany;
  214 + }
  215 +
  216 + public String getNature() {
  217 + return nature;
  218 + }
  219 +
  220 + public void setNature(String nature) {
  221 + this.nature = nature;
  222 + }
  223 +
  224 + public String getLevel() {
  225 + return level;
  226 + }
  227 +
  228 + public void setLevel(String level) {
  229 + this.level = level;
  230 + }
  231 +
  232 + public Integer getDestroy() {
  233 + return destroy;
  234 + }
  235 +
  236 + public void setDestroy(Integer destroy) {
  237 + this.destroy = destroy;
  238 + }
  239 +
  240 + public Integer getSupperLine() {
  241 + return supperLine;
  242 + }
  243 +
  244 + public void setSupperLine(Integer supperLine) {
  245 + this.supperLine = supperLine;
  246 + }
  247 +
  248 + public String getEqLinecode() {
  249 + return eqLinecode;
  250 + }
  251 +
  252 + public void setEqLinecode(String eqLinecode) {
  253 + this.eqLinecode = eqLinecode;
  254 + }
  255 +
  256 + @XmlJavaTypeAdapter(DateTimeAdapter.class)
  257 + public Date getCreateDate() {
  258 + return createDate;
  259 + }
  260 +
  261 + public void setCreateDate(Date createDate) {
  262 + this.createDate = createDate;
  263 + }
  264 +
  265 + public Double getTotalMileage() {
  266 + return totalMileage;
  267 + }
  268 +
  269 + public void setTotalMileage(Double totalMileage) {
  270 + this.totalMileage = totalMileage;
  271 + }
  272 +
  273 + public Double getEarlyIntervalLg() {
  274 + return earlyIntervalLg;
  275 + }
  276 +
  277 + public void setEarlyIntervalLg(Double earlyIntervalLg) {
  278 + this.earlyIntervalLg = earlyIntervalLg;
  279 + }
  280 +
  281 + public Double getLateIntervalLg() {
  282 + return lateIntervalLg;
  283 + }
  284 +
  285 + public void setLateIntervalLg(Double lateIntervalLg) {
  286 + this.lateIntervalLg = lateIntervalLg;
  287 + }
  288 +
  289 + public Double getIntervalLg() {
  290 + return intervalLg;
  291 + }
  292 +
  293 + public void setIntervalLg(Double intervalLg) {
  294 + this.intervalLg = intervalLg;
  295 + }
  296 +
  297 + public Double getSpeedLimit() {
  298 + return speedLimit;
  299 + }
  300 +
  301 + public void setSpeedLimit(Double speedLimit) {
  302 + this.speedLimit = speedLimit;
  303 + }
  304 +
  305 + public Integer getLagStation() {
  306 + return lagStation;
  307 + }
  308 +
  309 + public void setLagStation(Integer lagStation) {
  310 + this.lagStation = lagStation;
  311 + }
  312 +
  313 + public Integer getSkip() {
  314 + return skip;
  315 + }
  316 +
  317 + public void setSkip(Integer skip) {
  318 + this.skip = skip;
  319 + }
  320 +
  321 + public Integer getSpeeding() {
  322 + return speeding;
  323 + }
  324 +
  325 + public void setSpeeding(Integer speeding) {
  326 + this.speeding = speeding;
  327 + }
  328 +
  329 + public Integer getCrossedLine() {
  330 + return crossedLine;
  331 + }
  332 +
  333 + public void setCrossedLine(Integer crossedLine) {
  334 + this.crossedLine = crossedLine;
  335 + }
  336 +
  337 + public Integer getOverflights() {
  338 + return overflights;
  339 + }
  340 +
  341 + public void setOverflights(Integer overflights) {
  342 + this.overflights = overflights;
  343 + }
  344 +
  345 + public String getShanghaiLinecode() {
  346 + return shanghaiLinecode;
  347 + }
  348 +
  349 + public void setShanghaiLinecode(String shanghaiLinecode) {
  350 + this.shanghaiLinecode = shanghaiLinecode;
  351 + }
  352 +
  353 + public int getLinePlayType() {
  354 + return linePlayType;
  355 + }
  356 +
  357 + public void setLinePlayType(int linePlayType) {
  358 + this.linePlayType = linePlayType;
  359 + }
  360 +
  361 + public int getRegion() {
  362 + return region;
  363 + }
  364 +
  365 + public void setRegion(int region) {
  366 + this.region = region;
  367 + }
  368 +
  369 + public Integer getInUse() {
  370 + return inUse;
  371 + }
  372 +
  373 + public void setInUse(Integer inUse) {
  374 + this.inUse = inUse;
  375 + }
  376 +
  377 + public Date getRevokeDate() {
  378 + return revokeDate;
  379 + }
  380 +
  381 + public void setRevokeDate(Date revokeDate) {
  382 + this.revokeDate = revokeDate;
  383 + }
  384 +}
... ...
src/main/java/com/bsth/server_rs/base_info/line/LineRestService.java
... ... @@ -27,6 +27,12 @@ public class LineRestService {
27 27 }
28 28  
29 29 @GET
  30 + @Path("/revoke")
  31 + public List<Line> findRevoke(){
  32 + return LineBufferData.findRevoke();
  33 + }
  34 +
  35 + @GET
30 36 @Path("/company/{companyId}")
31 37 public List<Line> findByCompany(@PathParam("companyId") String companyId) {
32 38 return companyId.equals("-9999") ? LineBufferData.findAll() : LineBufferData.findByCompany(companyId);
... ...
src/main/java/com/bsth/server_rs/base_info/line/buffer/LineBufferData.java
1   -package com.bsth.server_rs.base_info.line.buffer;
2   -
3   -import com.bsth.Application;
4   -import com.bsth.server_rs.base_info.line.Line;
5   -import com.google.common.collect.ArrayListMultimap;
6   -import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.boot.CommandLineRunner;
8   -import org.springframework.core.annotation.Order;
9   -import org.springframework.stereotype.Component;
10   -
11   -import java.util.ArrayList;
12   -import java.util.HashMap;
13   -import java.util.List;
14   -import java.util.Map;
15   -import java.util.concurrent.TimeUnit;
16   -
17   -/**
18   - * 线路数据缓存(自更新)
19   - * Created by panzhao on 2017/3/27.
20   - */
21   -@Component
22   -@Order(5)
23   -public class LineBufferData implements CommandLineRunner {
24   -
25   - @Autowired
26   - LineRefreshThread lineRefreshThread;
27   -
28   - private static List<Line> data;
29   - private static Map<String, Line> idMap;
30   - private static ArrayListMultimap<String, Line> companyListMap;
31   -
32   - public static List<Line> findAll(){
33   - return data;
34   - }
35   -
36   - public static Line findOne(String lineCode){
37   - return idMap.get(lineCode);
38   - }
39   -
40   - public static List<Line> findByCompany(String company){
41   - return companyListMap.get(company);
42   - }
43   -
44   - public static void replaceAll(List<Line> newData){
45   - data = newData;
46   - Map<String, Line> idMapCopy = new HashMap<>();
47   - ArrayListMultimap<String, Line> listMap = ArrayListMultimap.create();
48   -
49   - for(Line line : data){
50   - idMapCopy.put(line.getLineCode(), line);
51   - listMap.put(line.getCompany(), line);
52   - }
53   - idMap = idMapCopy;
54   -
55   - companyListMap = listMap;
56   - }
57   -
58   - @Override
59   - public void run(String... strings) throws Exception {
60   - Application.mainServices.scheduleWithFixedDelay(lineRefreshThread, 10, 60 * 60, TimeUnit.SECONDS);
61   - }
62   -
63   - public static List<String> findCodesByCompany(String company) {
64   - List<Line> list = companyListMap.get(company);
65   - List<String> codes = new ArrayList<>(list.size());
66   -
67   - for(Line line : list)
68   - codes.add(line.getLineCode());
69   - return codes;
70   - }
71   -}
  1 +package com.bsth.server_rs.base_info.line.buffer;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.server_rs.base_info.line.Line;
  5 +import com.google.common.collect.ArrayListMultimap;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.boot.CommandLineRunner;
  8 +import org.springframework.core.annotation.Order;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.HashMap;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +import java.util.concurrent.TimeUnit;
  16 +
  17 +/**
  18 + * 线路数据缓存(自更新)
  19 + * Created by panzhao on 2017/3/27.
  20 + */
  21 +@Component
  22 +@Order(5)
  23 +public class LineBufferData implements CommandLineRunner {
  24 +
  25 + @Autowired
  26 + LineRefreshThread lineRefreshThread;
  27 +
  28 + private static List<Line> data;
  29 + private static List<Line> revokeLines;
  30 + private static Map<String, Line> idMap;
  31 + private static ArrayListMultimap<String, Line> companyListMap;
  32 +
  33 + public static List<Line> findAll(){
  34 + return data;
  35 + }
  36 +
  37 + public static List<Line> findRevoke() { return revokeLines; }
  38 +
  39 + public static Line findOne(String lineCode){
  40 + return idMap.get(lineCode);
  41 + }
  42 +
  43 + public static List<Line> findByCompany(String company){
  44 + return companyListMap.get(company);
  45 + }
  46 +
  47 + public static void replaceAll(List<Line> newData){
  48 + data = newData;
  49 + Map<String, Line> idMapCopy = new HashMap<>();
  50 + ArrayListMultimap<String, Line> listMap = ArrayListMultimap.create();
  51 +
  52 + for(Line line : data){
  53 + idMapCopy.put(line.getLineCode(), line);
  54 + listMap.put(line.getCompany(), line);
  55 + }
  56 + idMap = idMapCopy;
  57 +
  58 + companyListMap = listMap;
  59 + }
  60 +
  61 + public static void replaceRevoke(List<Line> newData) {
  62 + revokeLines = newData;
  63 + }
  64 +
  65 + @Override
  66 + public void run(String... strings) throws Exception {
  67 + Application.mainServices.scheduleWithFixedDelay(lineRefreshThread, 10, 60 * 60, TimeUnit.SECONDS);
  68 + }
  69 +
  70 + public static List<String> findCodesByCompany(String company) {
  71 + List<Line> list = companyListMap.get(company);
  72 + List<String> codes = new ArrayList<>(list.size());
  73 +
  74 + for(Line line : list)
  75 + codes.add(line.getLineCode());
  76 + return codes;
  77 + }
  78 +}
... ...
src/main/java/com/bsth/server_rs/base_info/line/buffer/LineRefreshThread.java
1   -package com.bsth.server_rs.base_info.line.buffer;
2   -
3   -import com.bsth.server_rs.base_info.line.Line;
4   -import org.slf4j.Logger;
5   -import org.slf4j.LoggerFactory;
6   -import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.jdbc.core.BeanPropertyRowMapper;
8   -import org.springframework.jdbc.core.JdbcTemplate;
9   -import org.springframework.stereotype.Component;
10   -
11   -import java.util.ArrayList;
12   -import java.util.HashMap;
13   -import java.util.List;
14   -import java.util.Map;
15   -
16   -/**
17   - * Created by panzhao on 2017/3/27.
18   - */
19   -@Component
20   -public class LineRefreshThread extends Thread{
21   -
22   - @Autowired
23   - JdbcTemplate jdbcTemplate;
24   -
25   - Logger logger = LoggerFactory.getLogger(this.getClass());
26   -
27   - @Override
28   - public void run() {
29   -
30   - try {
31   - List<Line> list = jdbcTemplate.query("SELECT t1. NAME,t1.line_code,t1.start_station_name,t1.end_station_name,t1.start_station_first_time,t1.start_station_end_time,t1.end_station_first_time,t1.end_station_end_time,t1.company,t1.branche_company,t1.nature,t1.`level`,t1.destroy,t1.supper_line,t1.eq_linecode,t1.create_date,t2.total_mileage,t2.early_interval_lg,t2.late_interval_lg,t2.interval_lg,t2.speed_limit,t2.lag_station,t2.skip,t2.speeding,t2.crossed_line,t2.overflights,t1.shanghai_linecode, t1.line_play_type, t1.region, t1.in_use, t3.business_name company_name FROM bsth_c_line t1 LEFT JOIN bsth_c_line_information t2 ON t1.id = t2.line LEFT JOIN bsth_c_business t3 on t1.company = t3.business_code where t1.destroy=0",
32   - BeanPropertyRowMapper.newInstance(Line.class));
33   -
34   - Map<String, Line> map = new HashMap<>();
35   - //过滤数据,多条线路配人的保留一条
36   - for(Line line : list){
37   - map.put(line.getLineCode(), line);
38   - }
39   -
40   - if(list != null && list.size() > 0)
41   - LineBufferData.replaceAll(new ArrayList(map.values()));
42   - }catch (Exception e){
43   - logger.error("", e);
44   - }
45   - }
46   -}
  1 +package com.bsth.server_rs.base_info.line.buffer;
  2 +
  3 +import com.bsth.server_rs.base_info.line.Line;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  8 +import org.springframework.jdbc.core.JdbcTemplate;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.HashMap;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Created by panzhao on 2017/3/27.
  18 + */
  19 +@Component
  20 +public class LineRefreshThread extends Thread{
  21 +
  22 + @Autowired
  23 + JdbcTemplate jdbcTemplate;
  24 +
  25 + Logger logger = LoggerFactory.getLogger(this.getClass());
  26 +
  27 + @Override
  28 + public void run() {
  29 +
  30 + try {
  31 + List<Line> list = jdbcTemplate.query("SELECT t1. NAME,t1.line_code,t1.start_station_name,t1.end_station_name,t1.start_station_first_time,t1.start_station_end_time,t1.end_station_first_time,t1.end_station_end_time,t1.company,t1.branche_company,t1.nature,t1.`level`,t1.destroy,t1.supper_line,t1.eq_linecode,t1.create_date,t2.total_mileage,t2.early_interval_lg,t2.late_interval_lg,t2.interval_lg,t2.speed_limit,t2.lag_station,t2.skip,t2.speeding,t2.crossed_line,t2.overflights,t1.shanghai_linecode, t1.line_play_type, t1.region, t1.in_use, t3.business_name company_name,t1.revoke_date FROM bsth_c_line t1 LEFT JOIN bsth_c_line_information t2 ON t1.id = t2.line LEFT JOIN bsth_c_business t3 on t1.company = t3.business_code",
  32 + BeanPropertyRowMapper.newInstance(Line.class));
  33 +
  34 + Map<String, Line> map = new HashMap<>(), revokeMap = new HashMap<>();
  35 + //过滤数据,多条线路配人的保留一条
  36 + for(Line line : list){
  37 + if (0 == line.getDestroy()) {
  38 + map.put(line.getLineCode(), line);
  39 + } else if (1 == line.getDestroy()) {
  40 + revokeMap.put(line.getLineCode(), line);
  41 + }
  42 + }
  43 +
  44 + if(list != null && list.size() > 0) {
  45 + LineBufferData.replaceAll(new ArrayList(map.values()));
  46 + LineBufferData.replaceRevoke(new ArrayList(revokeMap.values()));
  47 + }
  48 + }catch (Exception e){
  49 + logger.error("", e);
  50 + }
  51 + }
  52 +}
... ...