Commit 070dd28f89936020febd7c0620ef4d81c9f3be47
1 parent
75ddc678
update...
Showing
26 changed files
with
1405 additions
and
52 deletions
src/main/java/com/bsth/CXFConfig.java
| 1 | package com.bsth; | 1 | package com.bsth; |
| 2 | 2 | ||
| 3 | import com.bsth.server_rs.AuthorizeInterceptor_IN; | 3 | import com.bsth.server_rs.AuthorizeInterceptor_IN; |
| 4 | +import com.bsth.server_rs.base_info.car.CarRestService; | ||
| 5 | +import com.bsth.server_rs.base_info.line.LineRestService; | ||
| 6 | +import com.bsth.server_rs.base_info.person.PersonRestService; | ||
| 4 | import com.bsth.server_rs.exception.AesExceptionMapper; | 7 | import com.bsth.server_rs.exception.AesExceptionMapper; |
| 5 | -import com.bsth.server_rs.base_info.line.LineServiceImpl; | 8 | +import com.bsth.server_rs.gps.GpsRestService; |
| 6 | import com.bsth.server_ws.attendance.AttendanceServiceSoap; | 9 | import com.bsth.server_ws.attendance.AttendanceServiceSoap; |
| 7 | import com.bsth.server_ws.park_station.CompanyServiceSoap; | 10 | import com.bsth.server_ws.park_station.CompanyServiceSoap; |
| 8 | import com.bsth.server_ws.waybill.LD_ServiceSoap; | 11 | import com.bsth.server_ws.waybill.LD_ServiceSoap; |
| @@ -40,7 +43,7 @@ public class CXFConfig { | @@ -40,7 +43,7 @@ public class CXFConfig { | ||
| 40 | return endpoint; | 43 | return endpoint; |
| 41 | } | 44 | } |
| 42 | 45 | ||
| 43 | - @Bean | 46 | + @Bean |
| 44 | public Endpoint ldServiceEndpoint() { | 47 | public Endpoint ldServiceEndpoint() { |
| 45 | EndpointImpl endpoint = new EndpointImpl(springBus(), new LD_ServiceSoap()); | 48 | EndpointImpl endpoint = new EndpointImpl(springBus(), new LD_ServiceSoap()); |
| 46 | endpoint.publish("/LD_Service"); | 49 | endpoint.publish("/LD_Service"); |
| @@ -70,7 +73,7 @@ public class CXFConfig { | @@ -70,7 +73,7 @@ public class CXFConfig { | ||
| 70 | JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); | 73 | JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); |
| 71 | endpoint.setBus(springBus()); | 74 | endpoint.setBus(springBus()); |
| 72 | endpoint.setAddress("/rest"); | 75 | endpoint.setAddress("/rest"); |
| 73 | - endpoint.setServiceBeans(Arrays.<Object>asList(new LineServiceImpl())); | 76 | + endpoint.setServiceBeans(Arrays.<Object>asList(new LineRestService(), new CarRestService(), new PersonRestService(), new GpsRestService())); |
| 74 | endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); | 77 | endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); |
| 75 | //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); | 78 | //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); |
| 76 | endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); | 79 | endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); |
src/main/java/com/bsth/server_rs/AuthorizeInterceptor_IN.java
| @@ -33,6 +33,7 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> i | @@ -33,6 +33,7 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> i | ||
| 33 | private static final String TIMESTAMP = "timestamp"; | 33 | private static final String TIMESTAMP = "timestamp"; |
| 34 | private static final String NONCE = "nonce"; | 34 | private static final String NONCE = "nonce"; |
| 35 | private static final String PASSWORD = "password"; | 35 | private static final String PASSWORD = "password"; |
| 36 | + private static final int MAX_TIME_DIFF = 1000 * 60 * 10; | ||
| 36 | 37 | ||
| 37 | static UserService userService; | 38 | static UserService userService; |
| 38 | 39 | ||
| @@ -45,6 +46,7 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> i | @@ -45,6 +46,7 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> i | ||
| 45 | @Override | 46 | @Override |
| 46 | public void handleMessage(Message message) throws Fault { | 47 | public void handleMessage(Message message) throws Fault { |
| 47 | 48 | ||
| 49 | + long t = System.currentTimeMillis(); | ||
| 48 | if (message.get(Message.QUERY_STRING) == null) { | 50 | if (message.get(Message.QUERY_STRING) == null) { |
| 49 | throw new AesException(AesException.MISS_SIGN); | 51 | throw new AesException(AesException.MISS_SIGN); |
| 50 | } | 52 | } |
| @@ -67,6 +69,16 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> i | @@ -67,6 +69,16 @@ public class AuthorizeInterceptor_IN extends AbstractPhaseInterceptor<Message> i | ||
| 67 | if (!map.containsKey(TIMESTAMP)) { | 69 | if (!map.containsKey(TIMESTAMP)) { |
| 68 | throw new AesException(AesException.MISS_TIMESTAMP); | 70 | throw new AesException(AesException.MISS_TIMESTAMP); |
| 69 | } | 71 | } |
| 72 | + | ||
| 73 | + try{ | ||
| 74 | + long timestamp = Long.parseLong(map.get(TIMESTAMP)); | ||
| 75 | + if(Math.abs(t - timestamp) > MAX_TIME_DIFF){ | ||
| 76 | + throw new AesException(AesException.INVALID_TIMESTAMP); | ||
| 77 | + } | ||
| 78 | + }catch(Exception e){ | ||
| 79 | + throw new AesException(AesException.INVALID_TIMESTAMP); | ||
| 80 | + } | ||
| 81 | + | ||
| 70 | if (!map.containsKey(NONCE)) { | 82 | if (!map.containsKey(NONCE)) { |
| 71 | throw new AesException(AesException.MISS_NONCE); | 83 | throw new AesException(AesException.MISS_NONCE); |
| 72 | } | 84 | } |
src/main/java/com/bsth/server_rs/adapter/DateAdapter_yMd.java
0 → 100644
| 1 | +package com.bsth.server_rs.adapter; | ||
| 2 | + | ||
| 3 | +import org.joda.time.format.DateTimeFormat; | ||
| 4 | +import org.joda.time.format.DateTimeFormatter; | ||
| 5 | + | ||
| 6 | +import javax.xml.bind.annotation.adapters.XmlAdapter; | ||
| 7 | +import java.util.Date; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 时间格式处理 yyyy-MM-dd | ||
| 11 | + * Created by panzhao on 2017/3/28. | ||
| 12 | + */ | ||
| 13 | +public class DateAdapter_yMd extends XmlAdapter<String, Date> { | ||
| 14 | + | ||
| 15 | + private static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 16 | + | ||
| 17 | + @Override | ||
| 18 | + public Date unmarshal(String v) throws Exception { | ||
| 19 | + return fmtyyyyMMddHHmmss.parseDateTime(v).toDate(); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public String marshal(Date v) throws Exception { | ||
| 24 | + return fmtyyyyMMddHHmmss.print(v.getTime()); | ||
| 25 | + } | ||
| 26 | +} |
src/main/java/com/bsth/server_rs/adapter/DateAdapter.java renamed to src/main/java/com/bsth/server_rs/adapter/DateAdapter_yMdHms.java
| @@ -10,7 +10,7 @@ import java.util.Date; | @@ -10,7 +10,7 @@ import java.util.Date; | ||
| 10 | * 时间格式处理 yyyy-MM-dd HH:mm:ss | 10 | * 时间格式处理 yyyy-MM-dd HH:mm:ss |
| 11 | * Created by panzhao on 2017/3/28. | 11 | * Created by panzhao on 2017/3/28. |
| 12 | */ | 12 | */ |
| 13 | -public class DateAdapter extends XmlAdapter<String, Date> { | 13 | +public class DateAdapter_yMdHms extends XmlAdapter<String, Date> { |
| 14 | 14 | ||
| 15 | private static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); | 15 | private static DateTimeFormatter fmtyyyyMMddHHmmss = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); |
| 16 | 16 |
src/main/java/com/bsth/server_rs/base_info/car/Car.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.car; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.adapter.DateAdapter_yMd; | ||
| 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 | + * Created by panzhao on 2017/3/30. | ||
| 13 | + */ | ||
| 14 | +@XmlRootElement | ||
| 15 | +public class Car implements Serializable { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 主键Id | ||
| 19 | + */ | ||
| 20 | + private Integer id; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 自编号/内部编号 | ||
| 24 | + */ | ||
| 25 | + private String insideCode; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 公司代码 | ||
| 29 | + */ | ||
| 30 | + private String businessCode; | ||
| 31 | + /** | ||
| 32 | + * 分公司编码 | ||
| 33 | + */ | ||
| 34 | + private String brancheCompanyCode; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 车牌号 | ||
| 38 | + */ | ||
| 39 | + private String carPlate; | ||
| 40 | + /** | ||
| 41 | + * 供应商名称 | ||
| 42 | + */ | ||
| 43 | + private String supplierName; | ||
| 44 | + /** | ||
| 45 | + * 设备终端号 | ||
| 46 | + */ | ||
| 47 | + private String equipmentCode; | ||
| 48 | + | ||
| 49 | + // 以下信息来自总公司的业务系统,可能需要调用相关接口 | ||
| 50 | + /** | ||
| 51 | + * 车型类别 | ||
| 52 | + */ | ||
| 53 | + private String carClass; | ||
| 54 | + /** | ||
| 55 | + * 技术速度 | ||
| 56 | + */ | ||
| 57 | + private Double speed; | ||
| 58 | + /** | ||
| 59 | + * 座位数 | ||
| 60 | + */ | ||
| 61 | + private Integer carSeatnNumber; | ||
| 62 | + /** | ||
| 63 | + * 载客标准 | ||
| 64 | + */ | ||
| 65 | + private String carStandard; | ||
| 66 | + /** | ||
| 67 | + * 标准油耗(开空调) | ||
| 68 | + */ | ||
| 69 | + private Double kburnStandard; | ||
| 70 | + /** | ||
| 71 | + * 标准油耗(关空调) | ||
| 72 | + */ | ||
| 73 | + private Double gburnStandard; | ||
| 74 | + /** | ||
| 75 | + * 报废号 | ||
| 76 | + */ | ||
| 77 | + private String scrapCode; | ||
| 78 | + /** | ||
| 79 | + * 报废日期 | ||
| 80 | + */ | ||
| 81 | + private Date scrapDate; | ||
| 82 | + /** | ||
| 83 | + * 厂牌型号1 | ||
| 84 | + */ | ||
| 85 | + private String makeCodeOne; | ||
| 86 | + /** | ||
| 87 | + * 厂牌型号2 | ||
| 88 | + */ | ||
| 89 | + private String makeCodeTwo; | ||
| 90 | + /** | ||
| 91 | + * 车辆等级标准 | ||
| 92 | + */ | ||
| 93 | + private String carGride; | ||
| 94 | + /** | ||
| 95 | + * 出厂排放标准 | ||
| 96 | + */ | ||
| 97 | + private String emissionsStandard; | ||
| 98 | + /** | ||
| 99 | + * 发动机号码1 | ||
| 100 | + */ | ||
| 101 | + private String engineCodeOne; | ||
| 102 | + /** | ||
| 103 | + * 发动机号码2 | ||
| 104 | + */ | ||
| 105 | + private String engineCodeTwo; | ||
| 106 | + /** | ||
| 107 | + * 车架号码1 | ||
| 108 | + */ | ||
| 109 | + private String carNumberOne; | ||
| 110 | + /** | ||
| 111 | + * 车架号码2 | ||
| 112 | + */ | ||
| 113 | + private String carNumberTwo; | ||
| 114 | + /** | ||
| 115 | + * 启用日期 | ||
| 116 | + */ | ||
| 117 | + private Date openDate; | ||
| 118 | + /** | ||
| 119 | + * 取消日期 | ||
| 120 | + */ | ||
| 121 | + private Date closeDate; | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * 是否空调车 | ||
| 125 | + */ | ||
| 126 | + private Boolean hvacCar; | ||
| 127 | + /** | ||
| 128 | + * 有无人售票 | ||
| 129 | + */ | ||
| 130 | + private Boolean ticketType; | ||
| 131 | + /** | ||
| 132 | + * 是否有LED服务屏 | ||
| 133 | + */ | ||
| 134 | + private Boolean ledScreen; | ||
| 135 | + /** | ||
| 136 | + * 是否有TV视频 | ||
| 137 | + */ | ||
| 138 | + private Boolean tvVideoType; | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * 车辆类型 | ||
| 142 | + */ | ||
| 143 | + private String carType; | ||
| 144 | + /** | ||
| 145 | + * 是否机动车(机动车类型选择) | ||
| 146 | + */ | ||
| 147 | + private String vehicleStats; | ||
| 148 | + /** | ||
| 149 | + * 营运状态 | ||
| 150 | + */ | ||
| 151 | + private String operatorsState; | ||
| 152 | + /** | ||
| 153 | + * 营运证编码 | ||
| 154 | + */ | ||
| 155 | + private String serviceNo; | ||
| 156 | + /** | ||
| 157 | + * 是否电车(TODO:在原系统里没有,这里暂时留着) | ||
| 158 | + */ | ||
| 159 | + private Boolean sfdc; | ||
| 160 | + /** | ||
| 161 | + * 备注/描述 | ||
| 162 | + */ | ||
| 163 | + private String descriptions; | ||
| 164 | + | ||
| 165 | + /** | ||
| 166 | + * 视频编号 | ||
| 167 | + */ | ||
| 168 | + private String videoCode; | ||
| 169 | + /** | ||
| 170 | + * 是否报废 | ||
| 171 | + */ | ||
| 172 | + private Boolean scrapState; | ||
| 173 | + | ||
| 174 | + /** | ||
| 175 | + * RFID 车卡号 | ||
| 176 | + */ | ||
| 177 | + private String icRFID; | ||
| 178 | + | ||
| 179 | + /** | ||
| 180 | + * RFID 标签号 | ||
| 181 | + */ | ||
| 182 | + private String tagRFID; | ||
| 183 | + | ||
| 184 | + public Integer getId() { | ||
| 185 | + return id; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + public void setId(Integer id) { | ||
| 189 | + this.id = id; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + public String getInsideCode() { | ||
| 193 | + return insideCode; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public void setInsideCode(String insideCode) { | ||
| 197 | + this.insideCode = insideCode; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + public String getBusinessCode() { | ||
| 201 | + return businessCode; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + public void setBusinessCode(String businessCode) { | ||
| 205 | + this.businessCode = businessCode; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + public String getBrancheCompanyCode() { | ||
| 209 | + return brancheCompanyCode; | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + public void setBrancheCompanyCode(String brancheCompanyCode) { | ||
| 213 | + this.brancheCompanyCode = brancheCompanyCode; | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + public String getCarPlate() { | ||
| 217 | + return carPlate; | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + public void setCarPlate(String carPlate) { | ||
| 221 | + this.carPlate = carPlate; | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + public String getSupplierName() { | ||
| 225 | + return supplierName; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + public void setSupplierName(String supplierName) { | ||
| 229 | + this.supplierName = supplierName; | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + public String getEquipmentCode() { | ||
| 233 | + return equipmentCode; | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + public void setEquipmentCode(String equipmentCode) { | ||
| 237 | + this.equipmentCode = equipmentCode; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + public String getCarClass() { | ||
| 241 | + return carClass; | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + public void setCarClass(String carClass) { | ||
| 245 | + this.carClass = carClass; | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | + public Double getSpeed() { | ||
| 249 | + return speed; | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + public void setSpeed(Double speed) { | ||
| 253 | + this.speed = speed; | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + public Integer getCarSeatnNumber() { | ||
| 257 | + return carSeatnNumber; | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + public void setCarSeatnNumber(Integer carSeatnNumber) { | ||
| 261 | + this.carSeatnNumber = carSeatnNumber; | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + public String getCarStandard() { | ||
| 265 | + return carStandard; | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + public void setCarStandard(String carStandard) { | ||
| 269 | + this.carStandard = carStandard; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + public Double getKburnStandard() { | ||
| 273 | + return kburnStandard; | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + public void setKburnStandard(Double kburnStandard) { | ||
| 277 | + this.kburnStandard = kburnStandard; | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + public Double getGburnStandard() { | ||
| 281 | + return gburnStandard; | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + public void setGburnStandard(Double gburnStandard) { | ||
| 285 | + this.gburnStandard = gburnStandard; | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + public String getScrapCode() { | ||
| 289 | + return scrapCode; | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + public void setScrapCode(String scrapCode) { | ||
| 293 | + this.scrapCode = scrapCode; | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + @XmlJavaTypeAdapter(DateAdapter_yMd.class) | ||
| 297 | + public Date getScrapDate() { | ||
| 298 | + return scrapDate; | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + public void setScrapDate(Date scrapDate) { | ||
| 302 | + this.scrapDate = scrapDate; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + public String getMakeCodeOne() { | ||
| 306 | + return makeCodeOne; | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + public void setMakeCodeOne(String makeCodeOne) { | ||
| 310 | + this.makeCodeOne = makeCodeOne; | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + public String getMakeCodeTwo() { | ||
| 314 | + return makeCodeTwo; | ||
| 315 | + } | ||
| 316 | + | ||
| 317 | + public void setMakeCodeTwo(String makeCodeTwo) { | ||
| 318 | + this.makeCodeTwo = makeCodeTwo; | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + public String getCarGride() { | ||
| 322 | + return carGride; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + public void setCarGride(String carGride) { | ||
| 326 | + this.carGride = carGride; | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + public String getEmissionsStandard() { | ||
| 330 | + return emissionsStandard; | ||
| 331 | + } | ||
| 332 | + | ||
| 333 | + public void setEmissionsStandard(String emissionsStandard) { | ||
| 334 | + this.emissionsStandard = emissionsStandard; | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + public String getEngineCodeOne() { | ||
| 338 | + return engineCodeOne; | ||
| 339 | + } | ||
| 340 | + | ||
| 341 | + public void setEngineCodeOne(String engineCodeOne) { | ||
| 342 | + this.engineCodeOne = engineCodeOne; | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + public String getEngineCodeTwo() { | ||
| 346 | + return engineCodeTwo; | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + public void setEngineCodeTwo(String engineCodeTwo) { | ||
| 350 | + this.engineCodeTwo = engineCodeTwo; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + public String getCarNumberOne() { | ||
| 354 | + return carNumberOne; | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + public void setCarNumberOne(String carNumberOne) { | ||
| 358 | + this.carNumberOne = carNumberOne; | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + public String getCarNumberTwo() { | ||
| 362 | + return carNumberTwo; | ||
| 363 | + } | ||
| 364 | + | ||
| 365 | + public void setCarNumberTwo(String carNumberTwo) { | ||
| 366 | + this.carNumberTwo = carNumberTwo; | ||
| 367 | + } | ||
| 368 | + | ||
| 369 | + @XmlJavaTypeAdapter(DateAdapter_yMd.class) | ||
| 370 | + public Date getOpenDate() { | ||
| 371 | + return openDate; | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + public void setOpenDate(Date openDate) { | ||
| 375 | + this.openDate = openDate; | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + @XmlJavaTypeAdapter(DateAdapter_yMd.class) | ||
| 379 | + public Date getCloseDate() { | ||
| 380 | + return closeDate; | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + public void setCloseDate(Date closeDate) { | ||
| 384 | + this.closeDate = closeDate; | ||
| 385 | + } | ||
| 386 | + | ||
| 387 | + public Boolean getHvacCar() { | ||
| 388 | + return hvacCar; | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + public void setHvacCar(Boolean hvacCar) { | ||
| 392 | + this.hvacCar = hvacCar; | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + public Boolean getTicketType() { | ||
| 396 | + return ticketType; | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + public void setTicketType(Boolean ticketType) { | ||
| 400 | + this.ticketType = ticketType; | ||
| 401 | + } | ||
| 402 | + | ||
| 403 | + public Boolean getLedScreen() { | ||
| 404 | + return ledScreen; | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + public void setLedScreen(Boolean ledScreen) { | ||
| 408 | + this.ledScreen = ledScreen; | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + public Boolean getTvVideoType() { | ||
| 412 | + return tvVideoType; | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + public void setTvVideoType(Boolean tvVideoType) { | ||
| 416 | + this.tvVideoType = tvVideoType; | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + public String getCarType() { | ||
| 420 | + return carType; | ||
| 421 | + } | ||
| 422 | + | ||
| 423 | + public void setCarType(String carType) { | ||
| 424 | + this.carType = carType; | ||
| 425 | + } | ||
| 426 | + | ||
| 427 | + public String getVehicleStats() { | ||
| 428 | + return vehicleStats; | ||
| 429 | + } | ||
| 430 | + | ||
| 431 | + public void setVehicleStats(String vehicleStats) { | ||
| 432 | + this.vehicleStats = vehicleStats; | ||
| 433 | + } | ||
| 434 | + | ||
| 435 | + public String getOperatorsState() { | ||
| 436 | + return operatorsState; | ||
| 437 | + } | ||
| 438 | + | ||
| 439 | + public void setOperatorsState(String operatorsState) { | ||
| 440 | + this.operatorsState = operatorsState; | ||
| 441 | + } | ||
| 442 | + | ||
| 443 | + public String getServiceNo() { | ||
| 444 | + return serviceNo; | ||
| 445 | + } | ||
| 446 | + | ||
| 447 | + public void setServiceNo(String serviceNo) { | ||
| 448 | + this.serviceNo = serviceNo; | ||
| 449 | + } | ||
| 450 | + | ||
| 451 | + public Boolean getSfdc() { | ||
| 452 | + return sfdc; | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + public void setSfdc(Boolean sfdc) { | ||
| 456 | + this.sfdc = sfdc; | ||
| 457 | + } | ||
| 458 | + | ||
| 459 | + public String getDescriptions() { | ||
| 460 | + return descriptions; | ||
| 461 | + } | ||
| 462 | + | ||
| 463 | + public void setDescriptions(String descriptions) { | ||
| 464 | + this.descriptions = descriptions; | ||
| 465 | + } | ||
| 466 | + | ||
| 467 | + public String getVideoCode() { | ||
| 468 | + return videoCode; | ||
| 469 | + } | ||
| 470 | + | ||
| 471 | + public void setVideoCode(String videoCode) { | ||
| 472 | + this.videoCode = videoCode; | ||
| 473 | + } | ||
| 474 | + | ||
| 475 | + public Boolean getScrapState() { | ||
| 476 | + return scrapState; | ||
| 477 | + } | ||
| 478 | + | ||
| 479 | + public void setScrapState(Boolean scrapState) { | ||
| 480 | + this.scrapState = scrapState; | ||
| 481 | + } | ||
| 482 | + | ||
| 483 | + public String getIcRFID() { | ||
| 484 | + return icRFID; | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + public void setIcRFID(String icRFID) { | ||
| 488 | + this.icRFID = icRFID; | ||
| 489 | + } | ||
| 490 | + | ||
| 491 | + public String getTagRFID() { | ||
| 492 | + return tagRFID; | ||
| 493 | + } | ||
| 494 | + | ||
| 495 | + public void setTagRFID(String tagRFID) { | ||
| 496 | + this.tagRFID = tagRFID; | ||
| 497 | + } | ||
| 498 | +} |
src/main/java/com/bsth/server_rs/base_info/car/CarRestService.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.car; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.car.buffer.CarBufferData; | ||
| 4 | + | ||
| 5 | +import javax.ws.rs.GET; | ||
| 6 | +import javax.ws.rs.Path; | ||
| 7 | +import javax.ws.rs.PathParam; | ||
| 8 | +import javax.ws.rs.Produces; | ||
| 9 | +import javax.ws.rs.core.MediaType; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Created by panzhao on 2017/3/30. | ||
| 14 | + */ | ||
| 15 | +@Path("/car") | ||
| 16 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 17 | +public class CarRestService { | ||
| 18 | + | ||
| 19 | + @GET | ||
| 20 | + @Path("/all") | ||
| 21 | + public List<Car> findAll(){ | ||
| 22 | + return CarBufferData.findAll(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @GET | ||
| 26 | + @Path("/company/{companyId}") | ||
| 27 | + public List<Car> findByCompany(@PathParam("companyId") String companyId) { | ||
| 28 | + return companyId.equals("-9999") ? CarBufferData.findAll() : CarBufferData.findByCompany(companyId); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @GET | ||
| 32 | + @Path("/{nbbm}") | ||
| 33 | + public Car findOne(@PathParam("nbbm") String nbbm) { | ||
| 34 | + return CarBufferData.findOne(nbbm); | ||
| 35 | + } | ||
| 36 | +} |
src/main/java/com/bsth/server_rs/base_info/car/CarService.java deleted
100644 → 0
src/main/java/com/bsth/server_rs/base_info/car/buffer/CarBufferData.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.car.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.server_rs.base_info.car.Car; | ||
| 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.HashMap; | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.Map; | ||
| 14 | +import java.util.concurrent.TimeUnit; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 车辆数据缓存 | ||
| 18 | + * Created by panzhao on 2017/3/30. | ||
| 19 | + */ | ||
| 20 | +@Component | ||
| 21 | +@Order(6) | ||
| 22 | +public class CarBufferData implements CommandLineRunner { | ||
| 23 | + | ||
| 24 | + private static List<Car> data; | ||
| 25 | + private static Map<String, Car> idMap; | ||
| 26 | + private static ArrayListMultimap<String, Car> companyListMap; | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + CarRefreshThread carRefreshThread; | ||
| 30 | + | ||
| 31 | + public static List<Car> findAll(){ | ||
| 32 | + return data; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public static Car findOne(String nbbm){ | ||
| 36 | + return idMap.get(nbbm); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public static List<Car> findByCompany(String company){ | ||
| 40 | + return companyListMap.get(company); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public static void replaceAll(List<Car> newData){ | ||
| 44 | + data = newData; | ||
| 45 | + Map<String, Car> idMapCopy = new HashMap<>(); | ||
| 46 | + ArrayListMultimap<String, Car> listMap = ArrayListMultimap.create(); | ||
| 47 | + | ||
| 48 | + for(Car car : data){ | ||
| 49 | + idMapCopy.put(car.getInsideCode(), car); | ||
| 50 | + listMap.put(car.getBusinessCode(), car); | ||
| 51 | + } | ||
| 52 | + idMap = idMapCopy; | ||
| 53 | + | ||
| 54 | + companyListMap = listMap; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public void run(String... strings) throws Exception { | ||
| 59 | + Application.mainServices.scheduleWithFixedDelay(carRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); | ||
| 60 | + } | ||
| 61 | +} |
src/main/java/com/bsth/server_rs/base_info/car/buffer/CarRefreshThread.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.car.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.car.Car; | ||
| 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.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by panzhao on 2017/3/30. | ||
| 15 | + */ | ||
| 16 | +@Component | ||
| 17 | +public class CarRefreshThread extends Thread{ | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + JdbcTemplate jdbcTemplate; | ||
| 21 | + | ||
| 22 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public void run() { | ||
| 26 | + | ||
| 27 | + try { | ||
| 28 | + | ||
| 29 | + List<Car> list = jdbcTemplate.query("select * from bsth_c_cars", BeanPropertyRowMapper.newInstance(Car.class)); | ||
| 30 | + if(list != null && list.size() > 0) | ||
| 31 | + CarBufferData.replaceAll(list); | ||
| 32 | + }catch (Exception e){ | ||
| 33 | + logger.error("", e); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} |
src/main/java/com/bsth/server_rs/base_info/line/Line.java
| 1 | package com.bsth.server_rs.base_info.line; | 1 | package com.bsth.server_rs.base_info.line; |
| 2 | 2 | ||
| 3 | -import com.bsth.server_rs.adapter.DateAdapter; | 3 | +import com.bsth.server_rs.adapter.DateAdapter_yMdHms; |
| 4 | 4 | ||
| 5 | import javax.xml.bind.annotation.XmlRootElement; | 5 | import javax.xml.bind.annotation.XmlRootElement; |
| 6 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | 6 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| @@ -155,10 +155,6 @@ public class Line implements Serializable { | @@ -155,10 +155,6 @@ public class Line implements Serializable { | ||
| 155 | */ | 155 | */ |
| 156 | private Integer warrantCar; | 156 | private Integer warrantCar; |
| 157 | 157 | ||
| 158 | - /** | ||
| 159 | - * 权证配车启用日期 报表需要的字段值 | ||
| 160 | - */ | ||
| 161 | - private Integer warrantDate; | ||
| 162 | 158 | ||
| 163 | /** | 159 | /** |
| 164 | * 线路规划类型 <0:双向;1:环线> int length(11) 运管处接口需要的字段 不能为空 | 160 | * 线路规划类型 <0:双向;1:环线> int length(11) 运管处接口需要的字段 不能为空 |
| @@ -351,6 +347,7 @@ public class Line implements Serializable { | @@ -351,6 +347,7 @@ public class Line implements Serializable { | ||
| 351 | this.endPhone = endPhone; | 347 | this.endPhone = endPhone; |
| 352 | } | 348 | } |
| 353 | 349 | ||
| 350 | + @XmlJavaTypeAdapter(DateAdapter_yMdHms.class) | ||
| 354 | public Date getOpenDate() { | 351 | public Date getOpenDate() { |
| 355 | return openDate; | 352 | return openDate; |
| 356 | } | 353 | } |
| @@ -391,14 +388,6 @@ public class Line implements Serializable { | @@ -391,14 +388,6 @@ public class Line implements Serializable { | ||
| 391 | this.warrantCar = warrantCar; | 388 | this.warrantCar = warrantCar; |
| 392 | } | 389 | } |
| 393 | 390 | ||
| 394 | - public Integer getWarrantDate() { | ||
| 395 | - return warrantDate; | ||
| 396 | - } | ||
| 397 | - | ||
| 398 | - public void setWarrantDate(Integer warrantDate) { | ||
| 399 | - this.warrantDate = warrantDate; | ||
| 400 | - } | ||
| 401 | - | ||
| 402 | public Integer getLinePlayType() { | 391 | public Integer getLinePlayType() { |
| 403 | return linePlayType; | 392 | return linePlayType; |
| 404 | } | 393 | } |
| @@ -415,7 +404,7 @@ public class Line implements Serializable { | @@ -415,7 +404,7 @@ public class Line implements Serializable { | ||
| 415 | this.descriptions = descriptions; | 404 | this.descriptions = descriptions; |
| 416 | } | 405 | } |
| 417 | 406 | ||
| 418 | - @XmlJavaTypeAdapter(DateAdapter.class) | 407 | + @XmlJavaTypeAdapter(DateAdapter_yMdHms.class) |
| 419 | public Date getCreateDate() { | 408 | public Date getCreateDate() { |
| 420 | return createDate; | 409 | return createDate; |
| 421 | } | 410 | } |
src/main/java/com/bsth/server_rs/base_info/line/LineServiceImpl.java renamed to src/main/java/com/bsth/server_rs/base_info/line/LineRestService.java
| @@ -15,17 +15,23 @@ import java.util.List; | @@ -15,17 +15,23 @@ import java.util.List; | ||
| 15 | */ | 15 | */ |
| 16 | @Path("/line") | 16 | @Path("/line") |
| 17 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | 17 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
| 18 | -public class LineServiceImpl { | 18 | +public class LineRestService { |
| 19 | + | ||
| 20 | + @GET | ||
| 21 | + @Path("/all") | ||
| 22 | + public List<Line> findAll(){ | ||
| 23 | + return LineBufferData.findAll(); | ||
| 24 | + } | ||
| 19 | 25 | ||
| 20 | @GET | 26 | @GET |
| 21 | @Path("/company/{companyId}") | 27 | @Path("/company/{companyId}") |
| 22 | - public List<Line> findAll(@PathParam("companyId") String companyId) { | 28 | + public List<Line> findByCompany(@PathParam("companyId") String companyId) { |
| 23 | return companyId.equals("-9999") ? LineBufferData.findAll() : LineBufferData.findByCompany(companyId); | 29 | return companyId.equals("-9999") ? LineBufferData.findAll() : LineBufferData.findByCompany(companyId); |
| 24 | } | 30 | } |
| 25 | 31 | ||
| 26 | @GET | 32 | @GET |
| 27 | - @Path("/{id}") | ||
| 28 | - public Line findOne(@PathParam("id") Integer id) { | ||
| 29 | - return LineBufferData.findOne(id); | 33 | + @Path("/{lineCode}") |
| 34 | + public Line findOne(@PathParam("lineCode") String lineCode) { | ||
| 35 | + return LineBufferData.findOne(lineCode); | ||
| 30 | } | 36 | } |
| 31 | } | 37 | } |
src/main/java/com/bsth/server_rs/base_info/line/buffer/LineBufferData.java
| @@ -25,15 +25,15 @@ public class LineBufferData implements CommandLineRunner { | @@ -25,15 +25,15 @@ public class LineBufferData implements CommandLineRunner { | ||
| 25 | LineRefreshThread lineRefreshThread; | 25 | LineRefreshThread lineRefreshThread; |
| 26 | 26 | ||
| 27 | private static List<Line> data; | 27 | private static List<Line> data; |
| 28 | - private static Map<Integer, Line> idMap; | 28 | + private static Map<String, Line> idMap; |
| 29 | private static ArrayListMultimap<String, Line> companyListMap; | 29 | private static ArrayListMultimap<String, Line> companyListMap; |
| 30 | 30 | ||
| 31 | public static List<Line> findAll(){ | 31 | public static List<Line> findAll(){ |
| 32 | return data; | 32 | return data; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | - public static Line findOne(Integer id){ | ||
| 36 | - return idMap.get(id); | 35 | + public static Line findOne(String lineCode){ |
| 36 | + return idMap.get(lineCode); | ||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | public static List<Line> findByCompany(String company){ | 39 | public static List<Line> findByCompany(String company){ |
| @@ -42,11 +42,11 @@ public class LineBufferData implements CommandLineRunner { | @@ -42,11 +42,11 @@ public class LineBufferData implements CommandLineRunner { | ||
| 42 | 42 | ||
| 43 | public static void replaceAll(List<Line> newData){ | 43 | public static void replaceAll(List<Line> newData){ |
| 44 | data = newData; | 44 | data = newData; |
| 45 | - Map<Integer, Line> idMapCopy = new HashMap<>(); | 45 | + Map<String, Line> idMapCopy = new HashMap<>(); |
| 46 | ArrayListMultimap<String, Line> listMap = ArrayListMultimap.create(); | 46 | ArrayListMultimap<String, Line> listMap = ArrayListMultimap.create(); |
| 47 | 47 | ||
| 48 | for(Line line : data){ | 48 | for(Line line : data){ |
| 49 | - idMapCopy.put(line.getId(), line); | 49 | + idMapCopy.put(line.getLineCode(), line); |
| 50 | listMap.put(line.getCompany(), line); | 50 | listMap.put(line.getCompany(), line); |
| 51 | } | 51 | } |
| 52 | idMap = idMapCopy; | 52 | idMap = idMapCopy; |
src/main/java/com/bsth/server_rs/base_info/person/PersonRestService.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.person; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.person.buffer.PersonBufferData; | ||
| 4 | + | ||
| 5 | +import javax.ws.rs.GET; | ||
| 6 | +import javax.ws.rs.Path; | ||
| 7 | +import javax.ws.rs.PathParam; | ||
| 8 | +import javax.ws.rs.Produces; | ||
| 9 | +import javax.ws.rs.core.MediaType; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Created by panzhao on 2017/3/28. | ||
| 14 | + */ | ||
| 15 | +@Path("/person") | ||
| 16 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 17 | +public class PersonRestService { | ||
| 18 | + | ||
| 19 | + @GET | ||
| 20 | + @Path("/all") | ||
| 21 | + public List<Personnel> findAll(){ | ||
| 22 | + return PersonBufferData.findAll(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @GET | ||
| 26 | + @Path("/company/{companyId}") | ||
| 27 | + public List<Personnel> findByCompany(@PathParam("companyId") String companyId) { | ||
| 28 | + return companyId.equals("-9999") ? PersonBufferData.findAll() : PersonBufferData.findByCompany(companyId); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @GET | ||
| 32 | + @Path("/{workId}") | ||
| 33 | + public Personnel findOne(@PathParam("workId") String workId) { | ||
| 34 | + return PersonBufferData.findOne(workId); | ||
| 35 | + } | ||
| 36 | +} |
src/main/java/com/bsth/server_rs/base_info/person/PersonService.java deleted
100644 → 0
src/main/java/com/bsth/server_rs/base_info/person/Personnel.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.person; | ||
| 2 | + | ||
| 3 | +import javax.xml.bind.annotation.XmlRootElement; | ||
| 4 | +import java.io.Serializable; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * @ClassName : Personnel(人员实体类) | ||
| 8 | + * @Author : bsth@lq | ||
| 9 | + * @Description : TODO(人员) | ||
| 10 | + * @Data :2016-04-27 | ||
| 11 | + * @Version 公交调度系统BS版 0.1 | ||
| 12 | + */ | ||
| 13 | +@XmlRootElement | ||
| 14 | +public class Personnel implements Serializable { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 公司编码 | ||
| 18 | + */ | ||
| 19 | + private String companyCode; | ||
| 20 | + /** | ||
| 21 | + * 分公司编码 | ||
| 22 | + */ | ||
| 23 | + private String brancheCompanyCode; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 工号 | ||
| 27 | + */ | ||
| 28 | + private String jobCode; | ||
| 29 | + /** | ||
| 30 | + * 姓名 | ||
| 31 | + */ | ||
| 32 | + private String personnelName; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 运营服务证书号 | ||
| 36 | + */ | ||
| 37 | + private String papersCode; | ||
| 38 | + /** | ||
| 39 | + * 一卡通工作卡号 | ||
| 40 | + */ | ||
| 41 | + private String icCardCode; | ||
| 42 | + /** | ||
| 43 | + * 性别(字典类型sexType) | ||
| 44 | + */ | ||
| 45 | + private String personnelType; | ||
| 46 | + /** | ||
| 47 | + * 所属岗位/工种(字典类型gzType) | ||
| 48 | + */ | ||
| 49 | + private String posts; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 身份证 | ||
| 53 | + */ | ||
| 54 | + private String card; | ||
| 55 | + | ||
| 56 | + public String getCard() { | ||
| 57 | + return card; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setCard(String card) { | ||
| 61 | + this.card = card; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 联系电话(TODO:在原系统里没有,这里暂时留着) | ||
| 66 | + */ | ||
| 67 | + private String telphone; | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * RFID 人卡IC号 | ||
| 72 | + */ | ||
| 73 | + private String icRFID; | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * RFID 人卡ID号 | ||
| 77 | + */ | ||
| 78 | + private String idRFID; | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * RFID 标签号 | ||
| 82 | + */ | ||
| 83 | + private String tagRFID; | ||
| 84 | + | ||
| 85 | + public String getCompanyCode() { | ||
| 86 | + return companyCode; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setCompanyCode(String companyCode) { | ||
| 90 | + this.companyCode = companyCode; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public String getBrancheCompanyCode() { | ||
| 94 | + return brancheCompanyCode; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setBrancheCompanyCode(String brancheCompanyCode) { | ||
| 98 | + this.brancheCompanyCode = brancheCompanyCode; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public String getJobCode() { | ||
| 102 | + return jobCode; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setJobCode(String jobCode) { | ||
| 106 | + this.jobCode = jobCode; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public String getPersonnelName() { | ||
| 110 | + return personnelName; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setPersonnelName(String personnelName) { | ||
| 114 | + this.personnelName = personnelName; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public String getPapersCode() { | ||
| 118 | + return papersCode; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setPapersCode(String papersCode) { | ||
| 122 | + this.papersCode = papersCode; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public String getIcCardCode() { | ||
| 126 | + return icCardCode; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public void setIcCardCode(String icCardCode) { | ||
| 130 | + this.icCardCode = icCardCode; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public String getPersonnelType() { | ||
| 134 | + return personnelType; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public void setPersonnelType(String personnelType) { | ||
| 138 | + this.personnelType = personnelType; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public String getPosts() { | ||
| 142 | + return posts; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public void setPosts(String posts) { | ||
| 146 | + this.posts = posts; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public String getTelphone() { | ||
| 150 | + return telphone; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public void setTelphone(String telphone) { | ||
| 154 | + this.telphone = telphone; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public String getIcRFID() { | ||
| 158 | + return icRFID; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public void setIcRFID(String icRFID) { | ||
| 162 | + this.icRFID = icRFID; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + public String getIdRFID() { | ||
| 166 | + return idRFID; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public void setIdRFID(String idRFID) { | ||
| 170 | + this.idRFID = idRFID; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public String getTagRFID() { | ||
| 174 | + return tagRFID; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + public void setTagRFID(String tagRFID) { | ||
| 178 | + this.tagRFID = tagRFID; | ||
| 179 | + } | ||
| 180 | +} |
src/main/java/com/bsth/server_rs/base_info/person/buffer/PersonBufferData.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.person.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.server_rs.base_info.person.Personnel; | ||
| 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.HashMap; | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.Map; | ||
| 14 | +import java.util.concurrent.TimeUnit; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * Created by panzhao on 2017/3/30. | ||
| 18 | + */ | ||
| 19 | +@Component | ||
| 20 | +@Order(7) | ||
| 21 | +public class PersonBufferData implements CommandLineRunner { | ||
| 22 | + | ||
| 23 | + @Autowired | ||
| 24 | + PersonRefreshThread personRefreshThread; | ||
| 25 | + | ||
| 26 | + private static List<Personnel> data; | ||
| 27 | + private static Map<String, Personnel> idMap; | ||
| 28 | + private static ArrayListMultimap<String, Personnel> companyListMap; | ||
| 29 | + | ||
| 30 | + public static List<Personnel> findAll() { | ||
| 31 | + return data; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public static Personnel findOne(String workId) { | ||
| 35 | + return idMap.get(workId); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public static List<Personnel> findByCompany(String company) { | ||
| 39 | + return companyListMap.get(company); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public static void replaceAll(List<Personnel> newData) { | ||
| 43 | + data = newData; | ||
| 44 | + Map<String, Personnel> idMapCopy = new HashMap<>(); | ||
| 45 | + ArrayListMultimap<String, Personnel> listMap = ArrayListMultimap.create(); | ||
| 46 | + | ||
| 47 | + for (Personnel p : data) { | ||
| 48 | + idMapCopy.put(p.getJobCode(), p); | ||
| 49 | + listMap.put(p.getCompanyCode(), p); | ||
| 50 | + } | ||
| 51 | + idMap = idMapCopy; | ||
| 52 | + | ||
| 53 | + companyListMap = listMap; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public void run(String... strings) throws Exception { | ||
| 58 | + Application.mainServices.scheduleWithFixedDelay(personRefreshThread, 10, 60 * 60, TimeUnit.SECONDS); | ||
| 59 | + } | ||
| 60 | +} |
src/main/java/com/bsth/server_rs/base_info/person/buffer/PersonRefreshThread.java
0 → 100644
| 1 | +package com.bsth.server_rs.base_info.person.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.base_info.person.Personnel; | ||
| 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.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by panzhao on 2017/3/27. | ||
| 15 | + */ | ||
| 16 | +@Component | ||
| 17 | +public class PersonRefreshThread extends Thread{ | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + JdbcTemplate jdbcTemplate; | ||
| 21 | + | ||
| 22 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public void run() { | ||
| 26 | + | ||
| 27 | + try { | ||
| 28 | + List<Personnel> list = jdbcTemplate.query("select * from bsth_c_personnel",BeanPropertyRowMapper.newInstance(Personnel.class)); | ||
| 29 | + if(list != null && list.size() > 0) | ||
| 30 | + PersonBufferData.replaceAll(list); | ||
| 31 | + }catch (Exception e){ | ||
| 32 | + logger.error("", e); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | +} |
src/main/java/com/bsth/server_rs/exception/AesException.java
| @@ -13,6 +13,7 @@ public class AesException extends RuntimeException { | @@ -13,6 +13,7 @@ public class AesException extends RuntimeException { | ||
| 13 | public final static int SIGN_CHECK_ERROR = -40001; | 13 | public final static int SIGN_CHECK_ERROR = -40001; |
| 14 | public final static int SIGN_CHECK_FAIL = -40002; | 14 | public final static int SIGN_CHECK_FAIL = -40002; |
| 15 | public final static int INVALID_PWD = -40003; | 15 | public final static int INVALID_PWD = -40003; |
| 16 | + public final static int INVALID_TIMESTAMP = -40004; | ||
| 16 | 17 | ||
| 17 | private int code; | 18 | private int code; |
| 18 | 19 | ||
| @@ -31,7 +32,9 @@ public class AesException extends RuntimeException { | @@ -31,7 +32,9 @@ public class AesException extends RuntimeException { | ||
| 31 | case SIGN_CHECK_ERROR: | 32 | case SIGN_CHECK_ERROR: |
| 32 | return "签名校验时出现异常"; | 33 | return "签名校验时出现异常"; |
| 33 | case SIGN_CHECK_FAIL: | 34 | case SIGN_CHECK_FAIL: |
| 34 | - return "签名校验失败"; | 35 | + return "无效的签名"; |
| 36 | + case INVALID_TIMESTAMP: | ||
| 37 | + return "无效的时间戳"; | ||
| 35 | default: | 38 | default: |
| 36 | return null; | 39 | return null; |
| 37 | } | 40 | } |
src/main/java/com/bsth/server_rs/exception/AesExceptionMapper.java
| 1 | package com.bsth.server_rs.exception; | 1 | package com.bsth.server_rs.exception; |
| 2 | 2 | ||
| 3 | +import com.google.common.base.Splitter; | ||
| 3 | import org.apache.cxf.jaxrs.ext.MessageContext; | 4 | import org.apache.cxf.jaxrs.ext.MessageContext; |
| 4 | 5 | ||
| 5 | import javax.ws.rs.core.Context; | 6 | import javax.ws.rs.core.Context; |
| 6 | import javax.ws.rs.core.Response; | 7 | import javax.ws.rs.core.Response; |
| 7 | import javax.ws.rs.ext.ExceptionMapper; | 8 | import javax.ws.rs.ext.ExceptionMapper; |
| 9 | +import java.util.List; | ||
| 8 | import java.util.Locale; | 10 | import java.util.Locale; |
| 9 | 11 | ||
| 10 | /** | 12 | /** |
| @@ -27,8 +29,24 @@ public class AesExceptionMapper implements ExceptionMapper<AesException> { | @@ -27,8 +29,24 @@ public class AesExceptionMapper implements ExceptionMapper<AesException> { | ||
| 27 | rb.entity(entity); | 29 | rb.entity(entity); |
| 28 | 30 | ||
| 29 | String accept = mc.getHttpServletRequest().getHeader("Accept"); | 31 | String accept = mc.getHttpServletRequest().getHeader("Accept"); |
| 30 | - rb.type(accept); | 32 | + rb.type(getAccept(accept)); |
| 31 | rb.language(Locale.SIMPLIFIED_CHINESE); | 33 | rb.language(Locale.SIMPLIFIED_CHINESE); |
| 32 | return rb.build(); | 34 | return rb.build(); |
| 33 | } | 35 | } |
| 36 | + | ||
| 37 | + public String getAccept(String accept){ | ||
| 38 | + List<String> list = Splitter.on(",").splitToList(accept) | ||
| 39 | + ,subList; | ||
| 40 | + for(String item : list){ | ||
| 41 | + subList = Splitter.on(";").splitToList(item); | ||
| 42 | + for(String c : subList){ | ||
| 43 | + if(c.equals("application/xml") | ||
| 44 | + || c.equals("application/json")){ | ||
| 45 | + | ||
| 46 | + return c; | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + return accept; | ||
| 51 | + } | ||
| 34 | } | 52 | } |
src/main/java/com/bsth/server_rs/gps/GpsEntity.java
0 → 100644
| 1 | +package com.bsth.server_rs.gps; | ||
| 2 | + | ||
| 3 | +import javax.xml.bind.annotation.XmlRootElement; | ||
| 4 | +import java.io.Serializable; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * | ||
| 8 | + * @ClassName: GpsRealData | ||
| 9 | + * @Description: TODO(HTTP接口的实时GPS数据) | ||
| 10 | + * @author PanZhao | ||
| 11 | + * @date 2016年5月11日 下午4:32:07 | ||
| 12 | + * | ||
| 13 | + */ | ||
| 14 | +@XmlRootElement | ||
| 15 | +public class GpsEntity implements Serializable{ | ||
| 16 | + | ||
| 17 | + /** 公司代码 */ | ||
| 18 | + private Integer companyCode; | ||
| 19 | + | ||
| 20 | + /** 线路编码 */ | ||
| 21 | + private String lineId; | ||
| 22 | + | ||
| 23 | + /** 设备编码 */ | ||
| 24 | + private String deviceId; | ||
| 25 | + | ||
| 26 | + /** 停车场编码 */ | ||
| 27 | + private String carparkNo; | ||
| 28 | + | ||
| 29 | + /** 站点编码 */ | ||
| 30 | + private String stopNo; | ||
| 31 | + | ||
| 32 | + /** 站点名称 */ | ||
| 33 | + private String stationName; | ||
| 34 | + | ||
| 35 | + /** 经度 */ | ||
| 36 | + private Float lon; | ||
| 37 | + | ||
| 38 | + /** 纬度 */ | ||
| 39 | + private Float lat; | ||
| 40 | + | ||
| 41 | + /** 发送时间戳 */ | ||
| 42 | + private Long timestamp; | ||
| 43 | + | ||
| 44 | + /** 速度 */ | ||
| 45 | + private Float speed; | ||
| 46 | + | ||
| 47 | + /** 方向(角度) */ | ||
| 48 | + private Float direction; | ||
| 49 | + | ||
| 50 | + /** 营运状态( 0 营运 ,1 非营运, -1 无效) */ | ||
| 51 | + private Integer state; | ||
| 52 | + | ||
| 53 | + /** 上下行(0 上行 , 1 下行 , -1 无效) */ | ||
| 54 | + private Integer upDown; | ||
| 55 | + | ||
| 56 | + /** 车辆内部编码 */ | ||
| 57 | + private String nbbm; | ||
| 58 | + | ||
| 59 | + /** 预计到达终点时间 */ | ||
| 60 | + private Float expectStopTime; | ||
| 61 | + | ||
| 62 | + private int version; | ||
| 63 | + | ||
| 64 | + /** 异常状态 */ | ||
| 65 | + private String abnormalStatus; | ||
| 66 | + | ||
| 67 | + /** 越界距离 */ | ||
| 68 | + private double outOfBoundDistance; | ||
| 69 | + | ||
| 70 | + /** gps是否有效 设备端发送的状态 */ | ||
| 71 | + private int valid; | ||
| 72 | + | ||
| 73 | + public Integer getCompanyCode() { | ||
| 74 | + return companyCode; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public void setCompanyCode(Integer companyCode) { | ||
| 78 | + this.companyCode = companyCode; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public String getDeviceId() { | ||
| 82 | + return deviceId; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setDeviceId(String deviceId) { | ||
| 86 | + this.deviceId = deviceId; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public String getCarparkNo() { | ||
| 90 | + return carparkNo; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setCarparkNo(String carparkNo) { | ||
| 94 | + this.carparkNo = carparkNo; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public String getStopNo() { | ||
| 98 | + return stopNo; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setStopNo(String stopNo) { | ||
| 102 | + this.stopNo = stopNo; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public Float getLon() { | ||
| 106 | + return lon; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void setLon(Float lon) { | ||
| 110 | + this.lon = lon; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public Float getLat() { | ||
| 114 | + return lat; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public void setLat(Float lat) { | ||
| 118 | + this.lat = lat; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public Long getTimestamp() { | ||
| 122 | + return timestamp; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public void setTimestamp(Long timestamp) { | ||
| 126 | + this.timestamp = timestamp; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public Float getSpeed() { | ||
| 130 | + return speed; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public void setSpeed(Float speed) { | ||
| 134 | + this.speed = speed; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public Float getDirection() { | ||
| 138 | + return direction; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public void setDirection(Float direction) { | ||
| 142 | + this.direction = direction; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public Integer getState() { | ||
| 146 | + return state; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public void setState(Integer state) { | ||
| 150 | + this.state = state; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public Integer getUpDown() { | ||
| 154 | + return upDown; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public void setUpDown(Integer upDown) { | ||
| 158 | + this.upDown = upDown; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public String getNbbm() { | ||
| 162 | + return nbbm; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + public void setNbbm(String nbbm) { | ||
| 166 | + this.nbbm = nbbm; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public String getStationName() { | ||
| 170 | + return stationName; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public void setStationName(String stationName) { | ||
| 174 | + this.stationName = stationName; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + public Float getExpectStopTime() { | ||
| 178 | + return expectStopTime; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public void setExpectStopTime(Float expectStopTime) { | ||
| 182 | + this.expectStopTime = expectStopTime; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + public String getLineId() { | ||
| 186 | + return lineId; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + public void setLineId(String lineId) { | ||
| 190 | + this.lineId = lineId; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + public int getVersion() { | ||
| 194 | + return version; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + public void setVersion(int version) { | ||
| 198 | + this.version = version; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + public String getAbnormalStatus() { | ||
| 202 | + return abnormalStatus; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + public void setAbnormalStatus(String abnormalStatus) { | ||
| 206 | + this.abnormalStatus = abnormalStatus; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + public double getOutOfBoundDistance() { | ||
| 210 | + return outOfBoundDistance; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + public void setOutOfBoundDistance(double outOfBoundDistance) { | ||
| 214 | + this.outOfBoundDistance = outOfBoundDistance; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + public int getValid() { | ||
| 218 | + return valid; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + public void setValid(int valid) { | ||
| 222 | + this.valid = valid; | ||
| 223 | + } | ||
| 224 | +} |
src/main/java/com/bsth/server_rs/gps/GpsRealService.java deleted
100644 → 0
src/main/java/com/bsth/server_rs/gps/GpsRestService.java
0 → 100644
| 1 | +package com.bsth.server_rs.gps; | ||
| 2 | + | ||
| 3 | +import com.bsth.server_rs.gps.buffer.GpsRealDataBuffer; | ||
| 4 | + | ||
| 5 | +import javax.ws.rs.GET; | ||
| 6 | +import javax.ws.rs.Path; | ||
| 7 | +import javax.ws.rs.PathParam; | ||
| 8 | +import javax.ws.rs.Produces; | ||
| 9 | +import javax.ws.rs.core.MediaType; | ||
| 10 | +import java.util.Collection; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Created by panzhao on 2017/3/28. | ||
| 14 | + */ | ||
| 15 | +@Path("/gps") | ||
| 16 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 17 | +public class GpsRestService { | ||
| 18 | + | ||
| 19 | + @GET | ||
| 20 | + @Path("/{deviceId}") | ||
| 21 | + public GpsEntity findOne(@PathParam("deviceId") String deviceId){ | ||
| 22 | + return GpsRealDataBuffer.get(deviceId); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @GET | ||
| 26 | + @Path("/all") | ||
| 27 | + public Collection<GpsEntity> findAll(){ | ||
| 28 | + return GpsRealDataBuffer.all(); | ||
| 29 | + } | ||
| 30 | +} |
src/main/java/com/bsth/server_rs/gps/buffer/GpsRealDataBuffer.java
0 → 100644
| 1 | +package com.bsth.server_rs.gps.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.server_rs.gps.GpsEntity; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.boot.CommandLineRunner; | ||
| 7 | +import org.springframework.core.annotation.Order; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.HashMap; | ||
| 12 | +import java.util.Map; | ||
| 13 | +import java.util.concurrent.TimeUnit; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Created by panzhao on 2017/3/30. | ||
| 17 | + */ | ||
| 18 | +@Component | ||
| 19 | +@Order(8) | ||
| 20 | +public class GpsRealDataBuffer implements CommandLineRunner { | ||
| 21 | + | ||
| 22 | + private static Map<String, GpsEntity> realMap; | ||
| 23 | + | ||
| 24 | + @Autowired | ||
| 25 | + GpsRefreshThread gpsRefreshThread; | ||
| 26 | + | ||
| 27 | + static{ | ||
| 28 | + realMap = new HashMap<>(); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public static void put(GpsEntity gps){ | ||
| 32 | + realMap.put(gps.getDeviceId(), gps); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public static GpsEntity get(String device){ | ||
| 36 | + return realMap.get(device); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public static Collection<GpsEntity> all(){ | ||
| 40 | + return realMap.values(); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + @Override | ||
| 44 | + public void run(String... strings) throws Exception { | ||
| 45 | + Application.mainServices.scheduleWithFixedDelay(gpsRefreshThread, 10, 6, TimeUnit.SECONDS); | ||
| 46 | + } | ||
| 47 | +} |
src/main/java/com/bsth/server_rs/gps/buffer/GpsRefreshThread.java
0 → 100644
| 1 | +package com.bsth.server_rs.gps.buffer; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import com.bsth.server_rs.gps.GpsEntity; | ||
| 6 | +import com.bsth.util.ConfigUtil; | ||
| 7 | +import org.apache.http.HttpEntity; | ||
| 8 | +import org.apache.http.client.config.RequestConfig; | ||
| 9 | +import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 10 | +import org.apache.http.client.methods.HttpGet; | ||
| 11 | +import org.apache.http.impl.client.CloseableHttpClient; | ||
| 12 | +import org.apache.http.impl.client.HttpClients; | ||
| 13 | +import org.slf4j.Logger; | ||
| 14 | +import org.slf4j.LoggerFactory; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | + | ||
| 17 | +import java.io.BufferedReader; | ||
| 18 | +import java.io.InputStreamReader; | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Created by panzhao on 2017/3/30. | ||
| 23 | + */ | ||
| 24 | +@Component | ||
| 25 | +public class GpsRefreshThread extends Thread{ | ||
| 26 | + | ||
| 27 | + static String url; | ||
| 28 | + | ||
| 29 | + static { | ||
| 30 | + url = ConfigUtil.get("http.gps.real.url"); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public void run() { | ||
| 37 | + try { | ||
| 38 | + CloseableHttpClient httpClient = null; | ||
| 39 | + List<GpsEntity> rs = null; | ||
| 40 | + httpClient = HttpClients.createDefault(); | ||
| 41 | + //超时时间 | ||
| 42 | + RequestConfig requestConfig = RequestConfig.custom() | ||
| 43 | + .setConnectTimeout(2000).setConnectionRequestTimeout(1000) | ||
| 44 | + .setSocketTimeout(3000).build(); | ||
| 45 | + | ||
| 46 | + HttpGet get = new HttpGet(url); | ||
| 47 | + get.setConfig(requestConfig); | ||
| 48 | + | ||
| 49 | + CloseableHttpResponse response = httpClient.execute(get); | ||
| 50 | + | ||
| 51 | + HttpEntity entity = response.getEntity(); | ||
| 52 | + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | ||
| 53 | + StringBuffer stringBuffer = new StringBuffer(); | ||
| 54 | + String str = ""; | ||
| 55 | + while ((str = br.readLine()) != null) | ||
| 56 | + stringBuffer.append(str); | ||
| 57 | + | ||
| 58 | + JSONObject jsonObj = JSON.parseObject(stringBuffer.toString()); | ||
| 59 | + | ||
| 60 | + if (jsonObj != null) | ||
| 61 | + rs = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class); | ||
| 62 | + | ||
| 63 | + for(GpsEntity gps : rs){ | ||
| 64 | + GpsRealDataBuffer.put(gps); | ||
| 65 | + } | ||
| 66 | + }catch (Exception e){ | ||
| 67 | + logger.error("", e); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | +} |
src/main/resources/application-dev.properties
| @@ -32,3 +32,5 @@ spring.redis.port=28008 | @@ -32,3 +32,5 @@ spring.redis.port=28008 | ||
| 32 | 32 | ||
| 33 | http.control.service_data_url= http://127.0.0.1:9088/companyService | 33 | http.control.service_data_url= http://127.0.0.1:9088/companyService |
| 34 | http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki | 34 | http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki |
| 35 | + | ||
| 36 | +http.gps.real.url= http://27.115.69.123:8800/transport_server/rtgps/ |
src/main/resources/application-prod.properties
| @@ -30,4 +30,6 @@ spring.redis.password=bsth_control_001 | @@ -30,4 +30,6 @@ spring.redis.password=bsth_control_001 | ||
| 30 | spring.redis.port=28008 | 30 | spring.redis.port=28008 |
| 31 | 31 | ||
| 32 | http.control.service_data_url= http://10.10.150.20:9088/companyService | 32 | http.control.service_data_url= http://10.10.150.20:9088/companyService |
| 33 | -http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki | ||
| 34 | \ No newline at end of file | 33 | \ No newline at end of file |
| 34 | +http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki | ||
| 35 | + | ||
| 36 | +http.gps.real.url= http://10.10.150.21:8080/transport_server/rtgps/ | ||
| 35 | \ No newline at end of file | 37 | \ No newline at end of file |