Commit 183b2bece11842d85be73ab60843c80c5ae056da
1 parent
2f29f5bf
1.application.properties文件部分参数转换成SystemParam数据
Showing
26 changed files
with
739 additions
and
679 deletions
src/main/java/com/bsth/Application.java
| 1 | 1 | package com.bsth; |
| 2 | 2 | |
| 3 | +import com.bsth.data.SystemParamCache; | |
| 4 | +import com.bsth.service.SystemParamService; | |
| 3 | 5 | import com.fasterxml.jackson.annotation.JsonInclude; |
| 4 | 6 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | 7 | import com.fasterxml.jackson.databind.SerializationFeature; |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | 9 | import org.springframework.boot.SpringApplication; |
| 7 | 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 8 | 11 | import org.springframework.boot.builder.SpringApplicationBuilder; |
| ... | ... | @@ -22,6 +25,9 @@ public class Application extends SpringBootServletInitializer { |
| 22 | 25 | |
| 23 | 26 | public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(21); |
| 24 | 27 | |
| 28 | + @Autowired | |
| 29 | + private SystemParamCache systemParamCache; | |
| 30 | + | |
| 25 | 31 | @Override |
| 26 | 32 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
| 27 | 33 | return application.sources(Application.class); | ... | ... |
src/main/java/com/bsth/StartCommand.java
| 1 | -package com.bsth; | |
| 2 | - | |
| 3 | - | |
| 4 | -import com.bsth.security.SecurityMetadataSourceService; | |
| 5 | - | |
| 6 | -import org.slf4j.Logger; | |
| 7 | -import org.slf4j.LoggerFactory; | |
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | -import org.springframework.boot.CommandLineRunner; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * 随应用启动运行 | |
| 15 | - * @author PanZhao | |
| 16 | - * | |
| 17 | - */ | |
| 18 | -@Component | |
| 19 | -public class StartCommand implements CommandLineRunner{ | |
| 20 | - | |
| 21 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 22 | - | |
| 23 | - @Autowired | |
| 24 | - SecurityMetadataSourceService invocationSecurityMetadataSourceService; | |
| 25 | - | |
| 26 | - @Override | |
| 27 | - public void run(String... arg0){ | |
| 28 | - | |
| 29 | - try { | |
| 30 | - //启动时加载所有资源 | |
| 31 | - invocationSecurityMetadataSourceService.loadResourceDefine(); | |
| 32 | - | |
| 33 | - } catch (Exception e) { | |
| 34 | - e.printStackTrace(); | |
| 35 | - } | |
| 36 | - } | |
| 37 | -} | |
| 1 | +package com.bsth; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.bsth.security.SecurityMetadataSourceService; | |
| 5 | + | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.boot.CommandLineRunner; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 随应用启动运行 | |
| 15 | + * @author PanZhao | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +@Component | |
| 19 | +public class StartCommand implements CommandLineRunner{ | |
| 20 | + | |
| 21 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + SecurityMetadataSourceService invocationSecurityMetadataSourceService; | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + public void run(String... arg0){ | |
| 28 | + | |
| 29 | + try { | |
| 30 | + //启动时加载所有资源 | |
| 31 | + invocationSecurityMetadataSourceService.loadResourceDefine(); | |
| 32 | + } catch (Exception e) { | |
| 33 | + e.printStackTrace(); | |
| 34 | + } | |
| 35 | + } | |
| 36 | +} | ... | ... |
src/main/java/com/bsth/common/SystemParamKeys.java
| ... | ... | @@ -6,4 +6,38 @@ package com.bsth.common; |
| 6 | 6 | public class SystemParamKeys { |
| 7 | 7 | |
| 8 | 8 | public static final String SPECIAL_ROLES = "special.roles"; |
| 9 | + | |
| 10 | + public static final String URL_HTTP_GPS_REAL_CACHE = "url.http.gps.real.cache"; | |
| 11 | + | |
| 12 | + public static final String URL_HTTP_GPS_REAL = "url.http.gps.real"; | |
| 13 | + | |
| 14 | + public static final String URL_HTTP_DIRECTIVE = "url.http.directive"; | |
| 15 | + | |
| 16 | + public static final String URL_HTTP_RFID = "url.http.rfid"; | |
| 17 | + | |
| 18 | + public static final String URL_HTTP_REPORT = "url.http.report.%s"; | |
| 19 | + | |
| 20 | + public static final String URL_HTTP_TICKETING = "url.http.ticketing"; | |
| 21 | + | |
| 22 | + public static final String URL_HTTP_DSM_ACK = "url.http.dsm.ack"; | |
| 23 | + | |
| 24 | + public static final String URL_HTTP_CP_ACK = "url.http.cp.ack"; | |
| 25 | + | |
| 26 | + public static final String MAIL_ADMIN = "mail.admin"; | |
| 27 | + | |
| 28 | + public static final String MAIL_WAYBILL = "mail.waybill"; | |
| 29 | + | |
| 30 | + public static final String ENABLED_FIRST_LAST_GENERATION = "enabled.first.last.generation"; | |
| 31 | + | |
| 32 | + public static final String ENABLED_FILTER_SQL_INJECTION = "enabled.filter.sql.injection"; | |
| 33 | + | |
| 34 | + public static final String ENABLED_SSO = "enabled.sso"; | |
| 35 | + | |
| 36 | + public static final String SSO_SYSTEM_CODE = "sso.system.code"; | |
| 37 | + | |
| 38 | + public static final String URL_HTTP_SSO_LOGIN = "url.http.sso.login"; | |
| 39 | + | |
| 40 | + public static final String URL_HTTP_SSO_LOGOUT = "url.http.sso.logout"; | |
| 41 | + | |
| 42 | + public static final String URL_HTTP_SSO_AUTH = "url.http.sso.auth"; | |
| 9 | 43 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| ... | ... | @@ -4,10 +4,15 @@ import ch.qos.logback.classic.Level; |
| 4 | 4 | import ch.qos.logback.classic.LoggerContext; |
| 5 | 5 | import com.bsth.common.ResponseCode; |
| 6 | 6 | import com.bsth.data.BasicData; |
| 7 | +import com.bsth.data.SystemParamCache; | |
| 7 | 8 | import com.bsth.data.directive.DayOfDirectives; |
| 8 | 9 | import com.bsth.data.directive.DirectivesPstThread; |
| 10 | +import com.bsth.data.directive.GatewayHttpUtils; | |
| 9 | 11 | import com.bsth.data.gpsdata_v2.cache.GeoCacheData; |
| 10 | 12 | import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; |
| 13 | +import com.bsth.data.gpsdata_v2.load.GatewayHttpLoader; | |
| 14 | +import com.bsth.data.gpsdata_v2.load.SocketClientLoader; | |
| 15 | +import com.bsth.data.gpsdata_v2.rfid.RfidHttpLoader; | |
| 11 | 16 | import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; |
| 12 | 17 | import com.bsth.data.msg_queue.DirectivePushQueue; |
| 13 | 18 | import com.bsth.data.msg_queue.WebSocketPushQueue; |
| ... | ... | @@ -15,7 +20,9 @@ import com.bsth.data.pilot80.PilotReport; |
| 15 | 20 | import com.bsth.data.schedule.DayOfSchedule; |
| 16 | 21 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 17 | 22 | import com.bsth.filter.SQLInjectFilter; |
| 23 | +import com.bsth.security.SsoConfig; | |
| 18 | 24 | import com.bsth.service.SectionService; |
| 25 | +import com.bsth.service.SystemParamService; | |
| 19 | 26 | import com.bsth.service.schedule.utils.SpringUtils; |
| 20 | 27 | import com.bsth.util.MailUtils; |
| 21 | 28 | import com.bsth.websocket.handler.SendUtils; |
| ... | ... | @@ -73,6 +80,24 @@ public class AdminUtilsController { |
| 73 | 80 | @Autowired |
| 74 | 81 | private SectionService sectionService; |
| 75 | 82 | |
| 83 | + @Autowired | |
| 84 | + private SystemParamService systemParamService; | |
| 85 | + | |
| 86 | + @Autowired | |
| 87 | + private SocketClientLoader socketClientLoader; | |
| 88 | + | |
| 89 | + @Autowired | |
| 90 | + private GatewayHttpLoader gatewayHttpLoader; | |
| 91 | + | |
| 92 | + @Autowired | |
| 93 | + private GatewayHttpUtils gatewayHttpUtils; | |
| 94 | + | |
| 95 | + @Autowired | |
| 96 | + private RfidHttpLoader rfidHttpLoader; | |
| 97 | + | |
| 98 | + @Autowired | |
| 99 | + private SsoConfig ssoConfig; | |
| 100 | + | |
| 76 | 101 | /** |
| 77 | 102 | * 出现重复班次的车辆 |
| 78 | 103 | * |
| ... | ... | @@ -274,13 +299,11 @@ public class AdminUtilsController { |
| 274 | 299 | return "error"; |
| 275 | 300 | } |
| 276 | 301 | |
| 277 | - | |
| 278 | - | |
| 279 | - @RequestMapping("/changeEmail") | |
| 280 | - public String changeEmail(@RequestParam String email) { | |
| 302 | + @RequestMapping("/refreshBasicAll") | |
| 303 | + public String refreshBasicAll() { | |
| 281 | 304 | Map<String, Object> result = new HashMap<>(); |
| 282 | 305 | try { |
| 283 | - mailUtils.setEmailSendToAddress(email); | |
| 306 | + basicDataLoader.loadAllData(); | |
| 284 | 307 | return "success"; |
| 285 | 308 | } catch (Exception e) { |
| 286 | 309 | e.printStackTrace(); |
| ... | ... | @@ -289,11 +312,12 @@ public class AdminUtilsController { |
| 289 | 312 | return "error"; |
| 290 | 313 | } |
| 291 | 314 | |
| 292 | - @RequestMapping("/viewEmail") | |
| 293 | - public String viewEmail() { | |
| 315 | + @RequestMapping("/setInjectStr") | |
| 316 | + public String setInjectStr(@RequestParam String injectStr) { | |
| 294 | 317 | Map<String, Object> result = new HashMap<>(); |
| 295 | 318 | try { |
| 296 | - return mailUtils.getEmailSendToAddress(); | |
| 319 | + SQLInjectFilter.setInjStr(injectStr); | |
| 320 | + return "success"; | |
| 297 | 321 | } catch (Exception e) { |
| 298 | 322 | e.printStackTrace(); |
| 299 | 323 | } |
| ... | ... | @@ -301,11 +325,11 @@ public class AdminUtilsController { |
| 301 | 325 | return "error"; |
| 302 | 326 | } |
| 303 | 327 | |
| 304 | - @RequestMapping("/refreshBasicAll") | |
| 305 | - public String refreshBasicAll() { | |
| 306 | - Map<String, Object> result = new HashMap<>(); | |
| 328 | + @RequestMapping("/reloadSystemParam") | |
| 329 | + public String reloadSystemParam() { | |
| 307 | 330 | try { |
| 308 | - basicDataLoader.loadAllData(); | |
| 331 | + systemParamService.refresh(); | |
| 332 | + | |
| 309 | 333 | return "success"; |
| 310 | 334 | } catch (Exception e) { |
| 311 | 335 | e.printStackTrace(); |
| ... | ... | @@ -314,11 +338,16 @@ public class AdminUtilsController { |
| 314 | 338 | return "error"; |
| 315 | 339 | } |
| 316 | 340 | |
| 317 | - @RequestMapping("/setInjectStr") | |
| 318 | - public String setInjectStr(@RequestParam String injectStr) { | |
| 319 | - Map<String, Object> result = new HashMap<>(); | |
| 341 | + @RequestMapping("/applySystemParam") | |
| 342 | + public String applySystemParam() { | |
| 320 | 343 | try { |
| 321 | - SQLInjectFilter.setInjStr(injectStr); | |
| 344 | + socketClientLoader.afterPropertiesSet(); | |
| 345 | + gatewayHttpLoader.afterPropertiesSet(); | |
| 346 | + gatewayHttpUtils.afterPropertiesSet(); | |
| 347 | + rfidHttpLoader.afterPropertiesSet(); | |
| 348 | + ssoConfig.setSystemCode(SystemParamCache.getSsoSystemCode()); | |
| 349 | + ssoConfig.setSsoAuthUrl(SystemParamCache.getUrlHttpSsoAuth()); | |
| 350 | + | |
| 322 | 351 | return "success"; |
| 323 | 352 | } catch (Exception e) { |
| 324 | 353 | e.printStackTrace(); |
| ... | ... | @@ -327,24 +356,18 @@ public class AdminUtilsController { |
| 327 | 356 | return "error"; |
| 328 | 357 | } |
| 329 | 358 | |
| 330 | - @RequestMapping("/setSqlInjectEnabled") | |
| 331 | - public String setInjectStr(@RequestParam boolean sqlInjectEnabled) { | |
| 332 | - Map<String, Object> result = new HashMap<>(); | |
| 359 | + @RequestMapping("/reloadAndApplySystemParam") | |
| 360 | + public String reloadAndApplySystemParam() { | |
| 333 | 361 | try { |
| 334 | - sqlInjectFilter.setSqlInjectEnabled(sqlInjectEnabled); | |
| 335 | - return "success"; | |
| 336 | - } catch (Exception e) { | |
| 337 | - e.printStackTrace(); | |
| 338 | - } | |
| 362 | + systemParamService.refresh(); | |
| 339 | 363 | |
| 340 | - return "error"; | |
| 341 | - } | |
| 364 | + socketClientLoader.afterPropertiesSet(); | |
| 365 | + gatewayHttpLoader.afterPropertiesSet(); | |
| 366 | + gatewayHttpUtils.afterPropertiesSet(); | |
| 367 | + rfidHttpLoader.afterPropertiesSet(); | |
| 368 | + ssoConfig.setSystemCode(SystemParamCache.getSsoSystemCode()); | |
| 369 | + ssoConfig.setSsoAuthUrl(SystemParamCache.getUrlHttpSsoAuth()); | |
| 342 | 370 | |
| 343 | - @RequestMapping("/reloadSystemParam") | |
| 344 | - public String reloadSystemParam() { | |
| 345 | - Map<String, Object> result = new HashMap<>(); | |
| 346 | - try { | |
| 347 | - basicDataLoader.loadSystemParam(); | |
| 348 | 371 | return "success"; |
| 349 | 372 | } catch (Exception e) { |
| 350 | 373 | e.printStackTrace(); | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -6,6 +6,7 @@ import com.bsth.controller.BaseController; |
| 6 | 6 | import com.bsth.controller.realcontrol.dto.ChangePersonCar; |
| 7 | 7 | import com.bsth.controller.realcontrol.dto.DfsjChange; |
| 8 | 8 | import com.bsth.data.BasicData; |
| 9 | +import com.bsth.data.SystemParamCache; | |
| 9 | 10 | import com.bsth.data.schedule.DayOfSchedule; |
| 10 | 11 | import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; |
| 11 | 12 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| ... | ... | @@ -28,7 +29,6 @@ import org.joda.time.format.DateTimeFormatter; |
| 28 | 29 | import org.slf4j.Logger; |
| 29 | 30 | import org.slf4j.LoggerFactory; |
| 30 | 31 | import org.springframework.beans.factory.annotation.Autowired; |
| 31 | -import org.springframework.beans.factory.annotation.Value; | |
| 32 | 32 | import org.springframework.web.bind.annotation.*; |
| 33 | 33 | |
| 34 | 34 | import java.io.*; |
| ... | ... | @@ -50,13 +50,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 50 | 50 | @Autowired |
| 51 | 51 | DayOfSchedule dayOfSchedule; |
| 52 | 52 | |
| 53 | - @Value("${dsm.ack.url}") | |
| 54 | - private String dsmUrl; | |
| 55 | - | |
| 56 | - @Value("${cp.ack.url}") | |
| 57 | - private String cpUrl; | |
| 58 | - | |
| 59 | - @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST) | |
| 53 | + @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST) | |
| 60 | 54 | public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){ |
| 61 | 55 | return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm); |
| 62 | 56 | } |
| ... | ... | @@ -777,7 +771,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 777 | 771 | InputStream in = null; |
| 778 | 772 | SysUser user = SecurityUtils.getCurrentUser(); |
| 779 | 773 | DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); |
| 780 | - StringBuilder url = new StringBuilder(dsmUrl), uri = new StringBuilder(); | |
| 774 | + StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpDsmAck()), uri = new StringBuilder(); | |
| 781 | 775 | HttpURLConnection con = null; |
| 782 | 776 | try { |
| 783 | 777 | uri.append("ddyName=").append(URLEncoder.encode(user == null ? "admin" : user.getUserName(), "UTF-8")); |
| ... | ... | @@ -826,7 +820,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 826 | 820 | public Map<String, Object> ackCp(@RequestParam Map<String, Object> param){ |
| 827 | 821 | Map<String, Object> res = new HashMap<>(); |
| 828 | 822 | BufferedReader br = null; |
| 829 | - StringBuilder url = new StringBuilder(cpUrl); | |
| 823 | + StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpCpAck()); | |
| 830 | 824 | try { |
| 831 | 825 | url.append(param.get("id")); |
| 832 | 826 | CloseableHttpClient httpClient = HttpClientUtils.defaultHttpClient(url.toString()); | ... | ... |
src/main/java/com/bsth/data/BasicData.java
| ... | ... | @@ -105,9 +105,6 @@ public class BasicData { |
| 105 | 105 | // 线路编码_日期 等级 |
| 106 | 106 | public static Map<String, String> lineDate2Level; |
| 107 | 107 | |
| 108 | - | |
| 109 | - private static Map<String, SystemParam> key2param = new HashMap<>(); | |
| 110 | - | |
| 111 | 108 | static Logger logger = LoggerFactory.getLogger(BasicData.class); |
| 112 | 109 | |
| 113 | 110 | public static String getStationNameByCode(String code, String prefix){ |
| ... | ... | @@ -200,7 +197,6 @@ public class BasicData { |
| 200 | 197 | logger.info("load geo cache..,"); |
| 201 | 198 | geoCacheData.loadData(); |
| 202 | 199 | station2ParkBuffer.saveAll(); |
| 203 | - loadSystemParam(); | |
| 204 | 200 | logger.info("加载基础数据成功!,"); |
| 205 | 201 | } catch (Exception e) { |
| 206 | 202 | logger.error("加载基础数据时出现异常,", e); |
| ... | ... | @@ -456,25 +452,5 @@ public class BasicData { |
| 456 | 452 | |
| 457 | 453 | lineDate2Level = result; |
| 458 | 454 | } |
| 459 | - | |
| 460 | - /** | |
| 461 | - * 加载系统配置参数 | |
| 462 | - */ | |
| 463 | - public void loadSystemParam() { | |
| 464 | - Map<String, SystemParam> key2param = new HashMap<>(); | |
| 465 | - Iterator<SystemParam> systemParamIterator = systemParamRepository.findAll().iterator(); | |
| 466 | - while (systemParamIterator.hasNext()) { | |
| 467 | - SystemParam systemParam = systemParamIterator.next(); | |
| 468 | - key2param.put(systemParam.getKey(), systemParam); | |
| 469 | - } | |
| 470 | - | |
| 471 | - if (key2param.size() > 0) { | |
| 472 | - BasicData.key2param = key2param; | |
| 473 | - } | |
| 474 | - } | |
| 475 | - } | |
| 476 | - | |
| 477 | - public static Map<String, SystemParam> getSystemParam() { | |
| 478 | - return key2param; | |
| 479 | 455 | } |
| 480 | 456 | } | ... | ... |
src/main/java/com/bsth/data/SystemParamCache.java
0 → 100644
| 1 | +package com.bsth.data; | |
| 2 | + | |
| 3 | +import com.bsth.common.SystemParamKeys; | |
| 4 | +import com.bsth.service.SystemParamService; | |
| 5 | +import org.springframework.beans.factory.InitializingBean; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author Hill | |
| 11 | + */ | |
| 12 | +@Component | |
| 13 | +public class SystemParamCache implements InitializingBean { | |
| 14 | + | |
| 15 | + @Autowired | |
| 16 | + private SystemParamService systemParamService; | |
| 17 | + | |
| 18 | + private static SystemParamService systemParamService1; | |
| 19 | + | |
| 20 | + public static String getSpecialRoles() { | |
| 21 | + return systemParamService1.getValue(SystemParamKeys.SPECIAL_ROLES); | |
| 22 | + } | |
| 23 | + | |
| 24 | + public static String getUrlHttpGpsRealCache() { | |
| 25 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_GPS_REAL_CACHE); | |
| 26 | + } | |
| 27 | + | |
| 28 | + public static String getUrlHttpGpsReal() { | |
| 29 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_GPS_REAL); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public static String getUrlHttpDirective() { | |
| 33 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_DIRECTIVE); | |
| 34 | + } | |
| 35 | + | |
| 36 | + public static String getUrlHttpRfid() { | |
| 37 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_RFID); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public static String getUrlHttpReport(String param) { | |
| 41 | + return systemParamService1.getValue(String.format(SystemParamKeys.URL_HTTP_REPORT, param)); | |
| 42 | + } | |
| 43 | + | |
| 44 | + public static String getUrlHttpTicketing() { | |
| 45 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_TICKETING); | |
| 46 | + } | |
| 47 | + | |
| 48 | + public static String getUrlHttpDsmAck() { | |
| 49 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_DSM_ACK); | |
| 50 | + } | |
| 51 | + | |
| 52 | + public static String getUrlHttpCpAck() { | |
| 53 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_CP_ACK); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public static String getMailAdmin() { | |
| 57 | + return systemParamService1.getValue(SystemParamKeys.MAIL_ADMIN); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public static String getMailWaybill() { | |
| 61 | + return systemParamService1.getValue(SystemParamKeys.MAIL_WAYBILL); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public static boolean getEnabledFirstLastGeneration() { | |
| 65 | + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FIRST_LAST_GENERATION)); | |
| 66 | + } | |
| 67 | + | |
| 68 | + public static boolean getEnabledFilterSqlInjection() { | |
| 69 | + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_FILTER_SQL_INJECTION)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + public static boolean getEnabledSso() { | |
| 73 | + return Boolean.parseBoolean(systemParamService1.getValue(SystemParamKeys.ENABLED_SSO)); | |
| 74 | + } | |
| 75 | + | |
| 76 | + public static String getSsoSystemCode() { | |
| 77 | + return systemParamService1.getValue(SystemParamKeys.SSO_SYSTEM_CODE); | |
| 78 | + } | |
| 79 | + | |
| 80 | + public static String getUrlHttpSsoLogin() { | |
| 81 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_SSO_LOGIN); | |
| 82 | + } | |
| 83 | + | |
| 84 | + public static String getUrlHttpSsoLogout() { | |
| 85 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_SSO_LOGOUT); | |
| 86 | + } | |
| 87 | + | |
| 88 | + public static final String URL_HTTP_SSO_AUTH = "url.http.sso.auth"; | |
| 89 | + public static String getUrlHttpSsoAuth() { | |
| 90 | + return systemParamService1.getValue(SystemParamKeys.URL_HTTP_SSO_AUTH); | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Override | |
| 94 | + public void afterPropertiesSet() throws Exception { | |
| 95 | + systemParamService1 = systemParamService; | |
| 96 | + systemParamService1.refresh(); | |
| 97 | + } | |
| 98 | +} | ... | ... |
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
| 1 | -package com.bsth.data.directive; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 4 | -import com.bsth.util.ConfigUtil; | |
| 5 | -import org.apache.http.client.config.RequestConfig; | |
| 6 | -import org.apache.http.client.methods.CloseableHttpResponse; | |
| 7 | -import org.apache.http.client.methods.HttpPost; | |
| 8 | -import org.apache.http.entity.StringEntity; | |
| 9 | -import org.apache.http.impl.client.CloseableHttpClient; | |
| 10 | -import org.apache.http.impl.client.HttpClients; | |
| 11 | -import org.apache.http.util.EntityUtils; | |
| 12 | -import org.slf4j.Logger; | |
| 13 | -import org.slf4j.LoggerFactory; | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * @author PanZhao | |
| 17 | - * @ClassName: GatewayHttpUtils | |
| 18 | - * @Description: TODO(和网关HTTP通讯工具类) | |
| 19 | - * @date 2016年8月14日 下午9:50:46 | |
| 20 | - */ | |
| 21 | -public class GatewayHttpUtils { | |
| 22 | - static Logger logger = LoggerFactory.getLogger(GatewayHttpUtils.class); | |
| 23 | - | |
| 24 | - static String url; | |
| 25 | - static CloseableHttpClient httpClient = null; | |
| 26 | - static HttpPost post; | |
| 27 | - static RequestConfig requestConfig; | |
| 28 | - static CloseableHttpResponse response; | |
| 29 | - | |
| 30 | - static { | |
| 31 | - url = ConfigUtil.get("http.send.directive"); | |
| 32 | - httpClient = HttpClients.createDefault(); | |
| 33 | - post = new HttpPost(url); | |
| 34 | - requestConfig = RequestConfig.custom() | |
| 35 | - .setConnectTimeout(3000).setConnectionRequestTimeout(2000) | |
| 36 | - .setSocketTimeout(3000).build(); | |
| 37 | - post.setConfig(requestConfig); | |
| 38 | - } | |
| 39 | - | |
| 40 | - public static int postJson(String jsonStr) { | |
| 41 | - logger.info("send : " + jsonStr); | |
| 42 | - | |
| 43 | - int code = -1; | |
| 44 | - try { | |
| 45 | - post.setEntity(new StringEntity(jsonStr, "utf-8")); | |
| 46 | - | |
| 47 | - response = httpClient.execute(post); | |
| 48 | - | |
| 49 | - int statusCode = response.getStatusLine().getStatusCode(); | |
| 50 | - if(statusCode != 200){ | |
| 51 | - logger.error("http client status code: " + statusCode); | |
| 52 | - } | |
| 53 | - | |
| 54 | - JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); | |
| 55 | - if (null != json && json.getInteger("errCode") == 0) | |
| 56 | - code = 0; | |
| 57 | - else | |
| 58 | - logger.error("和网关http通讯失败,rs: " + json); | |
| 59 | - | |
| 60 | - if (null != response) | |
| 61 | - response.close(); | |
| 62 | - } catch (Exception e) { | |
| 63 | - logger.error("", e); | |
| 64 | - } | |
| 65 | - return code; | |
| 66 | - } | |
| 67 | -} | |
| 1 | +package com.bsth.data.directive; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSONObject; | |
| 4 | +import com.bsth.data.SystemParamCache; | |
| 5 | +import org.apache.http.client.config.RequestConfig; | |
| 6 | +import org.apache.http.client.methods.CloseableHttpResponse; | |
| 7 | +import org.apache.http.client.methods.HttpPost; | |
| 8 | +import org.apache.http.entity.StringEntity; | |
| 9 | +import org.apache.http.impl.client.CloseableHttpClient; | |
| 10 | +import org.apache.http.impl.client.HttpClients; | |
| 11 | +import org.apache.http.util.EntityUtils; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.factory.InitializingBean; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * @author PanZhao | |
| 19 | + * @ClassName: GatewayHttpUtils | |
| 20 | + * @Description: TODO(和网关HTTP通讯工具类) | |
| 21 | + * @date 2016年8月14日 下午9:50:46 | |
| 22 | + */ | |
| 23 | +@Component | |
| 24 | +public class GatewayHttpUtils implements InitializingBean { | |
| 25 | + static Logger logger = LoggerFactory.getLogger(GatewayHttpUtils.class); | |
| 26 | + | |
| 27 | + static String url; | |
| 28 | + static CloseableHttpClient httpClient = null; | |
| 29 | + static HttpPost post; | |
| 30 | + static RequestConfig requestConfig; | |
| 31 | + static CloseableHttpResponse response; | |
| 32 | + | |
| 33 | + public static int postJson(String jsonStr) { | |
| 34 | + logger.info("send : " + jsonStr); | |
| 35 | + | |
| 36 | + int code = -1; | |
| 37 | + try { | |
| 38 | + post.setEntity(new StringEntity(jsonStr, "utf-8")); | |
| 39 | + | |
| 40 | + response = httpClient.execute(post); | |
| 41 | + | |
| 42 | + int statusCode = response.getStatusLine().getStatusCode(); | |
| 43 | + if(statusCode != 200){ | |
| 44 | + logger.error("http client status code: " + statusCode); | |
| 45 | + } | |
| 46 | + | |
| 47 | + JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); | |
| 48 | + if (null != json && json.getInteger("errCode") == 0) | |
| 49 | + code = 0; | |
| 50 | + else | |
| 51 | + logger.error("和网关http通讯失败,rs: " + json); | |
| 52 | + | |
| 53 | + if (null != response) | |
| 54 | + response.close(); | |
| 55 | + } catch (Exception e) { | |
| 56 | + logger.error("", e); | |
| 57 | + } | |
| 58 | + return code; | |
| 59 | + } | |
| 60 | + | |
| 61 | + @Override | |
| 62 | + public void afterPropertiesSet() throws Exception { | |
| 63 | + url = SystemParamCache.getUrlHttpDirective(); | |
| 64 | + httpClient = HttpClients.createDefault(); | |
| 65 | + post = new HttpPost(url); | |
| 66 | + requestConfig = RequestConfig.custom() | |
| 67 | + .setConnectTimeout(3000).setConnectionRequestTimeout(2000) | |
| 68 | + .setSocketTimeout(3000).build(); | |
| 69 | + post.setConfig(requestConfig); | |
| 70 | + } | |
| 71 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/load/GatewayHttpLoader.java
| 1 | -package com.bsth.data.gpsdata_v2.load; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.bsth.data.BasicData; | |
| 5 | -import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 6 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 7 | -import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; | |
| 8 | -import com.bsth.util.ConfigUtil; | |
| 9 | -import org.apache.commons.lang3.StringUtils; | |
| 10 | -import org.apache.http.HttpEntity; | |
| 11 | -import org.apache.http.client.config.RequestConfig; | |
| 12 | -import org.apache.http.client.methods.CloseableHttpResponse; | |
| 13 | -import org.apache.http.client.methods.HttpGet; | |
| 14 | -import org.apache.http.impl.client.CloseableHttpClient; | |
| 15 | -import org.apache.http.impl.client.HttpClients; | |
| 16 | -import org.slf4j.Logger; | |
| 17 | -import org.slf4j.LoggerFactory; | |
| 18 | -import org.springframework.beans.BeansException; | |
| 19 | -import org.springframework.context.ApplicationContext; | |
| 20 | -import org.springframework.context.ApplicationContextAware; | |
| 21 | -import org.springframework.stereotype.Component; | |
| 22 | - | |
| 23 | -import java.io.BufferedReader; | |
| 24 | -import java.io.InputStreamReader; | |
| 25 | -import java.util.ArrayList; | |
| 26 | -import java.util.List; | |
| 27 | - | |
| 28 | -/** | |
| 29 | - * 从网关http 接口加载数据 | |
| 30 | - * Created by panzhao on 2017/11/15. | |
| 31 | - */ | |
| 32 | -@Component | |
| 33 | -public class GatewayHttpLoader implements ApplicationContextAware{ | |
| 34 | - | |
| 35 | - static Logger logger = LoggerFactory.getLogger(GatewayHttpLoader.class); | |
| 36 | - | |
| 37 | - static String url; | |
| 38 | - static List<GpsEntity> list; | |
| 39 | - static CloseableHttpClient httpClient = null; | |
| 40 | - static HttpGet get; | |
| 41 | - static RequestConfig requestConfig; | |
| 42 | - static CloseableHttpResponse response; | |
| 43 | - static HttpEntity entity; | |
| 44 | - static BufferedReader br; | |
| 45 | - | |
| 46 | - static GpsRealData gpsRealData; | |
| 47 | - | |
| 48 | - static{ | |
| 49 | - url = ConfigUtil.get("http.gps.real.url"); | |
| 50 | - list = new ArrayList<>(); | |
| 51 | - httpClient = HttpClients.createDefault(); | |
| 52 | - get = new HttpGet(url); | |
| 53 | - requestConfig = RequestConfig.custom() | |
| 54 | - .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | |
| 55 | - .setSocketTimeout(2500).build(); | |
| 56 | - get.setConfig(requestConfig); | |
| 57 | - } | |
| 58 | - | |
| 59 | - public static List<GpsEntity> load(){ | |
| 60 | - try{ | |
| 61 | - if(list.size() > 0) | |
| 62 | - list.clear(); | |
| 63 | - | |
| 64 | - response = httpClient.execute(get); | |
| 65 | - entity = response.getEntity(); | |
| 66 | - | |
| 67 | - logger.info("entity:" + entity + "get:" + get); | |
| 68 | - if(null == entity) | |
| 69 | - return list; | |
| 70 | - | |
| 71 | - br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 72 | - | |
| 73 | - StringBuilder sb = new StringBuilder(); | |
| 74 | - String str; | |
| 75 | - while ((str = br.readLine()) != null) | |
| 76 | - sb.append(str); | |
| 77 | - | |
| 78 | - logger.debug("gps:" + sb.toString()); | |
| 79 | - list = JSON.parseArray(JSON.parseObject(sb.toString()).getString("data"), GpsEntity.class); | |
| 80 | - //过滤掉无效的点位 | |
| 81 | - list = GpsDataUtils.clearInvalid(list); | |
| 82 | - | |
| 83 | - List<GpsEntity> ups = new ArrayList<>(); | |
| 84 | - String nbbm; | |
| 85 | - for (GpsEntity gps : list) { | |
| 86 | - if (StringUtils.isBlank(gps.getDeviceId())) | |
| 87 | - continue; | |
| 88 | - | |
| 89 | - if (gps_equals(gpsRealData.get(gps.getDeviceId()), gps)) | |
| 90 | - continue; | |
| 91 | - | |
| 92 | - nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId()); | |
| 93 | - gps.setNbbm(nbbm); | |
| 94 | - ups.add(gps); | |
| 95 | - } | |
| 96 | - list = ups; | |
| 97 | - | |
| 98 | - if (null != response) | |
| 99 | - response.close(); | |
| 100 | - }catch (Exception e){ | |
| 101 | - logger.error("", e); | |
| 102 | - } | |
| 103 | - return list; | |
| 104 | - } | |
| 105 | - | |
| 106 | - | |
| 107 | - private static boolean gps_equals(GpsEntity old, GpsEntity gps){ | |
| 108 | - if(old != null && | |
| 109 | - old.getTimestamp().equals(gps.getTimestamp()) && | |
| 110 | - old.getLat().equals(gps.getLat()) && | |
| 111 | - old.getLon().equals(gps.getLon())) | |
| 112 | - return true; | |
| 113 | - return false; | |
| 114 | - } | |
| 115 | - | |
| 116 | - @Override | |
| 117 | - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 118 | - gpsRealData = applicationContext.getBean(GpsRealData.class); | |
| 119 | - } | |
| 120 | -} | |
| 1 | +package com.bsth.data.gpsdata_v2.load; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.bsth.data.BasicData; | |
| 5 | +import com.bsth.data.SystemParamCache; | |
| 6 | +import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 7 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 8 | +import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; | |
| 9 | +import org.apache.commons.lang3.StringUtils; | |
| 10 | +import org.apache.http.HttpEntity; | |
| 11 | +import org.apache.http.client.config.RequestConfig; | |
| 12 | +import org.apache.http.client.methods.CloseableHttpResponse; | |
| 13 | +import org.apache.http.client.methods.HttpGet; | |
| 14 | +import org.apache.http.impl.client.CloseableHttpClient; | |
| 15 | +import org.apache.http.impl.client.HttpClients; | |
| 16 | +import org.slf4j.Logger; | |
| 17 | +import org.slf4j.LoggerFactory; | |
| 18 | +import org.springframework.beans.BeansException; | |
| 19 | +import org.springframework.beans.factory.InitializingBean; | |
| 20 | +import org.springframework.context.ApplicationContext; | |
| 21 | +import org.springframework.context.ApplicationContextAware; | |
| 22 | +import org.springframework.stereotype.Component; | |
| 23 | + | |
| 24 | +import java.io.BufferedReader; | |
| 25 | +import java.io.InputStreamReader; | |
| 26 | +import java.util.ArrayList; | |
| 27 | +import java.util.List; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * 从网关http 接口加载数据 | |
| 31 | + * Created by panzhao on 2017/11/15. | |
| 32 | + */ | |
| 33 | +@Component | |
| 34 | +public class GatewayHttpLoader implements ApplicationContextAware, InitializingBean { | |
| 35 | + | |
| 36 | + static Logger logger = LoggerFactory.getLogger(GatewayHttpLoader.class); | |
| 37 | + | |
| 38 | + static String url; | |
| 39 | + static List<GpsEntity> list; | |
| 40 | + static CloseableHttpClient httpClient = null; | |
| 41 | + static HttpGet get; | |
| 42 | + static RequestConfig requestConfig; | |
| 43 | + static CloseableHttpResponse response; | |
| 44 | + static HttpEntity entity; | |
| 45 | + static BufferedReader br; | |
| 46 | + | |
| 47 | + static GpsRealData gpsRealData; | |
| 48 | + | |
| 49 | + public static List<GpsEntity> load(){ | |
| 50 | + try{ | |
| 51 | + if(list.size() > 0) | |
| 52 | + list.clear(); | |
| 53 | + | |
| 54 | + response = httpClient.execute(get); | |
| 55 | + entity = response.getEntity(); | |
| 56 | + | |
| 57 | + logger.info("entity:" + entity + "get:" + get); | |
| 58 | + if(null == entity) | |
| 59 | + return list; | |
| 60 | + | |
| 61 | + br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 62 | + | |
| 63 | + StringBuilder sb = new StringBuilder(); | |
| 64 | + String str; | |
| 65 | + while ((str = br.readLine()) != null) | |
| 66 | + sb.append(str); | |
| 67 | + | |
| 68 | + logger.debug("gps:" + sb.toString()); | |
| 69 | + list = JSON.parseArray(JSON.parseObject(sb.toString()).getString("data"), GpsEntity.class); | |
| 70 | + //过滤掉无效的点位 | |
| 71 | + list = GpsDataUtils.clearInvalid(list); | |
| 72 | + | |
| 73 | + List<GpsEntity> ups = new ArrayList<>(); | |
| 74 | + String nbbm; | |
| 75 | + for (GpsEntity gps : list) { | |
| 76 | + if (StringUtils.isBlank(gps.getDeviceId())) | |
| 77 | + continue; | |
| 78 | + | |
| 79 | + if (gps_equals(gpsRealData.get(gps.getDeviceId()), gps)) | |
| 80 | + continue; | |
| 81 | + | |
| 82 | + nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId()); | |
| 83 | + gps.setNbbm(nbbm); | |
| 84 | + ups.add(gps); | |
| 85 | + } | |
| 86 | + list = ups; | |
| 87 | + | |
| 88 | + if (null != response) | |
| 89 | + response.close(); | |
| 90 | + }catch (Exception e){ | |
| 91 | + logger.error("", e); | |
| 92 | + } | |
| 93 | + return list; | |
| 94 | + } | |
| 95 | + | |
| 96 | + | |
| 97 | + private static boolean gps_equals(GpsEntity old, GpsEntity gps){ | |
| 98 | + if(old != null && | |
| 99 | + old.getTimestamp().equals(gps.getTimestamp()) && | |
| 100 | + old.getLat().equals(gps.getLat()) && | |
| 101 | + old.getLon().equals(gps.getLon())) | |
| 102 | + return true; | |
| 103 | + return false; | |
| 104 | + } | |
| 105 | + | |
| 106 | + @Override | |
| 107 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 108 | + gpsRealData = applicationContext.getBean(GpsRealData.class); | |
| 109 | + } | |
| 110 | + | |
| 111 | + @Override | |
| 112 | + public void afterPropertiesSet() throws Exception { | |
| 113 | + url = SystemParamCache.getUrlHttpGpsReal(); | |
| 114 | + list = new ArrayList<>(); | |
| 115 | + httpClient = HttpClients.createDefault(); | |
| 116 | + get = new HttpGet(url); | |
| 117 | + requestConfig = RequestConfig.custom() | |
| 118 | + .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | |
| 119 | + .setSocketTimeout(2500).build(); | |
| 120 | + get.setConfig(requestConfig); | |
| 121 | + } | |
| 122 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/load/SocketClientLoader.java
| 1 | -package com.bsth.data.gpsdata_v2.load; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.bsth.data.BasicData; | |
| 5 | -import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 6 | -import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; | |
| 7 | -import com.bsth.util.ConfigUtil; | |
| 8 | -import org.apache.http.HttpEntity; | |
| 9 | -import org.apache.http.client.config.RequestConfig; | |
| 10 | -import org.apache.http.client.methods.CloseableHttpResponse; | |
| 11 | -import org.apache.http.client.methods.HttpGet; | |
| 12 | -import org.apache.http.impl.client.CloseableHttpClient; | |
| 13 | -import org.apache.http.impl.client.HttpClients; | |
| 14 | -import org.slf4j.Logger; | |
| 15 | -import org.slf4j.LoggerFactory; | |
| 16 | -import org.springframework.stereotype.Component; | |
| 17 | - | |
| 18 | -import java.io.BufferedReader; | |
| 19 | -import java.io.InputStreamReader; | |
| 20 | -import java.util.ArrayList; | |
| 21 | -import java.util.List; | |
| 22 | - | |
| 23 | -/** | |
| 24 | - * 从专用的socket client 加载数据 | |
| 25 | - * Created by panzhao on 2017/11/15. | |
| 26 | - */ | |
| 27 | -@Component | |
| 28 | -public class SocketClientLoader { | |
| 29 | - | |
| 30 | - static Logger logger = LoggerFactory.getLogger(SocketClientLoader.class); | |
| 31 | - | |
| 32 | - static String url; | |
| 33 | - static List<GpsEntity> list; | |
| 34 | - static CloseableHttpClient httpClient = null; | |
| 35 | - static HttpGet get; | |
| 36 | - static RequestConfig requestConfig; | |
| 37 | - static CloseableHttpResponse response; | |
| 38 | - static HttpEntity entity; | |
| 39 | - static BufferedReader br; | |
| 40 | - | |
| 41 | - static { | |
| 42 | - url = ConfigUtil.get("http.gps.real.cache.url"); | |
| 43 | - list = new ArrayList<>(); | |
| 44 | - httpClient = HttpClients.createDefault(); | |
| 45 | - get = new HttpGet(url); | |
| 46 | - requestConfig = RequestConfig.custom() | |
| 47 | - .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | |
| 48 | - .setSocketTimeout(2500).build(); | |
| 49 | - get.setConfig(requestConfig); | |
| 50 | - } | |
| 51 | - | |
| 52 | - public static List<GpsEntity> load(){ | |
| 53 | - try { | |
| 54 | - if(list.size() > 0) | |
| 55 | - list.clear(); | |
| 56 | - logger.info("load start..."); | |
| 57 | - response = httpClient.execute(get); | |
| 58 | - entity = response.getEntity(); | |
| 59 | - if(null == entity) | |
| 60 | - return list; | |
| 61 | - | |
| 62 | - br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 63 | - StringBuilder sb = new StringBuilder(); | |
| 64 | - String str; | |
| 65 | - while ((str = br.readLine()) != null) | |
| 66 | - sb.append(str); | |
| 67 | - | |
| 68 | - list = JSON.parseArray(sb.toString(), GpsEntity.class); | |
| 69 | - | |
| 70 | - logger.info("load end ! size: " + list.size()); | |
| 71 | - //过滤掉无效的点位 | |
| 72 | - list = GpsDataUtils.clearInvalid(list); | |
| 73 | - | |
| 74 | - for (GpsEntity gps : list) { | |
| 75 | - gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())); | |
| 76 | - } | |
| 77 | - | |
| 78 | - if (null != response) | |
| 79 | - response.close(); | |
| 80 | - } catch (Exception e) { | |
| 81 | - logger.error("", e); | |
| 82 | - } | |
| 83 | - | |
| 84 | - return list; | |
| 85 | - } | |
| 86 | -} | |
| 1 | +package com.bsth.data.gpsdata_v2.load; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.bsth.data.BasicData; | |
| 5 | +import com.bsth.data.SystemParamCache; | |
| 6 | +import com.bsth.data.gpsdata_v2.entity.GpsEntity; | |
| 7 | +import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; | |
| 8 | +import org.apache.http.HttpEntity; | |
| 9 | +import org.apache.http.client.config.RequestConfig; | |
| 10 | +import org.apache.http.client.methods.CloseableHttpResponse; | |
| 11 | +import org.apache.http.client.methods.HttpGet; | |
| 12 | +import org.apache.http.impl.client.CloseableHttpClient; | |
| 13 | +import org.apache.http.impl.client.HttpClients; | |
| 14 | +import org.slf4j.Logger; | |
| 15 | +import org.slf4j.LoggerFactory; | |
| 16 | +import org.springframework.beans.factory.InitializingBean; | |
| 17 | +import org.springframework.stereotype.Component; | |
| 18 | + | |
| 19 | +import java.io.BufferedReader; | |
| 20 | +import java.io.InputStreamReader; | |
| 21 | +import java.util.ArrayList; | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * 从专用的socket client 加载数据 | |
| 26 | + * Created by panzhao on 2017/11/15. | |
| 27 | + */ | |
| 28 | +@Component | |
| 29 | +public class SocketClientLoader implements InitializingBean { | |
| 30 | + | |
| 31 | + static Logger logger = LoggerFactory.getLogger(SocketClientLoader.class); | |
| 32 | + | |
| 33 | + static String url; | |
| 34 | + static List<GpsEntity> list; | |
| 35 | + static CloseableHttpClient httpClient = null; | |
| 36 | + static HttpGet get; | |
| 37 | + static RequestConfig requestConfig; | |
| 38 | + static CloseableHttpResponse response; | |
| 39 | + static HttpEntity entity; | |
| 40 | + static BufferedReader br; | |
| 41 | + | |
| 42 | + public static List<GpsEntity> load(){ | |
| 43 | + try { | |
| 44 | + if(list.size() > 0) | |
| 45 | + list.clear(); | |
| 46 | + logger.info("load start..."); | |
| 47 | + response = httpClient.execute(get); | |
| 48 | + entity = response.getEntity(); | |
| 49 | + if(null == entity) | |
| 50 | + return list; | |
| 51 | + | |
| 52 | + br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 53 | + StringBuilder sb = new StringBuilder(); | |
| 54 | + String str; | |
| 55 | + while ((str = br.readLine()) != null) | |
| 56 | + sb.append(str); | |
| 57 | + | |
| 58 | + list = JSON.parseArray(sb.toString(), GpsEntity.class); | |
| 59 | + | |
| 60 | + logger.info("load end ! size: " + list.size()); | |
| 61 | + //过滤掉无效的点位 | |
| 62 | + list = GpsDataUtils.clearInvalid(list); | |
| 63 | + | |
| 64 | + for (GpsEntity gps : list) { | |
| 65 | + gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())); | |
| 66 | + } | |
| 67 | + | |
| 68 | + if (null != response) | |
| 69 | + response.close(); | |
| 70 | + } catch (Exception e) { | |
| 71 | + logger.error("", e); | |
| 72 | + } | |
| 73 | + | |
| 74 | + return list; | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public void afterPropertiesSet() throws Exception { | |
| 79 | + url = SystemParamCache.getUrlHttpGpsRealCache(); | |
| 80 | + list = new ArrayList<>(); | |
| 81 | + httpClient = HttpClients.createDefault(); | |
| 82 | + get = new HttpGet(url); | |
| 83 | + requestConfig = RequestConfig.custom() | |
| 84 | + .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | |
| 85 | + .setSocketTimeout(2500).build(); | |
| 86 | + get.setConfig(requestConfig); | |
| 87 | + } | |
| 88 | +} | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/rfid/RfidHttpLoader.java
| 1 | 1 | package com.bsth.data.gpsdata_v2.rfid; |
| 2 | 2 | |
| 3 | +import com.bsth.data.SystemParamCache; | |
| 3 | 4 | import com.bsth.data.gpsdata_v2.rfid.entity.RfidInfo; |
| 4 | -import com.bsth.util.ConfigUtil; | |
| 5 | 5 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 6 | 6 | import org.apache.commons.io.IOUtils; |
| 7 | 7 | import org.slf4j.Logger; |
| 8 | 8 | import org.slf4j.LoggerFactory; |
| 9 | +import org.springframework.beans.factory.InitializingBean; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 9 | 11 | |
| 10 | 12 | import java.io.ByteArrayOutputStream; |
| 11 | 13 | import java.io.IOException; |
| ... | ... | @@ -20,11 +22,12 @@ import java.util.List; |
| 20 | 22 | * @author hill |
| 21 | 23 | * @date |
| 22 | 24 | */ |
| 23 | -public class RfidHttpLoader { | |
| 25 | +@Component | |
| 26 | +public class RfidHttpLoader implements InitializingBean { | |
| 24 | 27 | |
| 25 | 28 | private final static Logger log = LoggerFactory.getLogger(RfidHttpLoader.class); |
| 26 | 29 | |
| 27 | - private static String RFID_URL = ConfigUtil.get("http.rfid.url"); | |
| 30 | + private static String RFID_URL; | |
| 28 | 31 | |
| 29 | 32 | public static List<RfidInfo> load() { |
| 30 | 33 | List<RfidInfo> result = new ArrayList<>(); |
| ... | ... | @@ -75,4 +78,9 @@ public class RfidHttpLoader { |
| 75 | 78 | |
| 76 | 79 | return result; |
| 77 | 80 | } |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public void afterPropertiesSet() throws Exception { | |
| 84 | + RFID_URL = SystemParamCache.getUrlHttpRfid(); | |
| 85 | + } | |
| 78 | 86 | } | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; |
| 5 | 5 | import com.bsth.common.Constants; |
| 6 | 6 | import com.bsth.common.ResponseCode; |
| 7 | 7 | import com.bsth.data.LineConfigData; |
| 8 | +import com.bsth.data.SystemParamCache; | |
| 8 | 9 | import com.bsth.data.gpsdata_v2.GpsRealData; |
| 9 | 10 | import com.bsth.data.gpsdata_v2.utils.GpsDataRecovery; |
| 10 | 11 | import com.bsth.data.schedule.f_a_l.FirstAndLastHandler; |
| ... | ... | @@ -27,7 +28,6 @@ import org.joda.time.format.DateTimeFormatter; |
| 27 | 28 | import org.slf4j.Logger; |
| 28 | 29 | import org.slf4j.LoggerFactory; |
| 29 | 30 | import org.springframework.beans.factory.annotation.Autowired; |
| 30 | -import org.springframework.beans.factory.annotation.Value; | |
| 31 | 31 | import org.springframework.dao.DataIntegrityViolationException; |
| 32 | 32 | import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| 33 | 33 | import org.springframework.jdbc.core.JdbcTemplate; |
| ... | ... | @@ -54,9 +54,6 @@ import java.util.concurrent.ConcurrentMap; |
| 54 | 54 | @Component |
| 55 | 55 | public class DayOfSchedule { |
| 56 | 56 | |
| 57 | - @Value("${ms.fl.generate}") | |
| 58 | - private boolean generate; | |
| 59 | - | |
| 60 | 57 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 61 | 58 | |
| 62 | 59 | //按线路分组的 “原始计划” 排班数据 |
| ... | ... | @@ -187,6 +184,7 @@ public class DayOfSchedule { |
| 187 | 184 | */ |
| 188 | 185 | public int reloadSch(String lineCode, String schDate, boolean forcePlan) { |
| 189 | 186 | try { |
| 187 | + boolean generate = SystemParamCache.getEnabledFirstLastGeneration(); | |
| 190 | 188 | List<ScheduleRealInfo> list; |
| 191 | 189 | |
| 192 | 190 | if (forcePlan) | ... | ... |
src/main/java/com/bsth/data/schedule/thread/CalcOilThread.java
| 1 | -package com.bsth.data.schedule.thread; | |
| 2 | - | |
| 3 | -import com.bsth.data.directive.DayOfDirectives; | |
| 4 | -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 5 | -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | |
| 6 | -import com.bsth.service.calc.CalcWaybillService; | |
| 7 | -import com.bsth.service.forms.BudgetService; | |
| 8 | -import com.bsth.service.oil.DlbService; | |
| 9 | -import com.bsth.data.safe_driv.SafeDrivCenter; | |
| 10 | -import com.bsth.service.oil.YlbService; | |
| 11 | -import com.bsth.service.report.SheetService; | |
| 12 | - | |
| 13 | -import org.slf4j.Logger; | |
| 14 | -import org.slf4j.LoggerFactory; | |
| 15 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | -import org.springframework.stereotype.Component; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * 计算油、公里加注量 线程 | |
| 20 | - * Created by panzhao on 2017/3/7. | |
| 21 | - */ | |
| 22 | -@Component | |
| 23 | -public class CalcOilThread extends Thread{ | |
| 24 | - | |
| 25 | - @Autowired | |
| 26 | - YlbService ylbService; | |
| 27 | - @Autowired | |
| 28 | - DlbService dlbService; | |
| 29 | - | |
| 30 | - @Autowired | |
| 31 | - SheetService sheetService; | |
| 32 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 33 | - | |
| 34 | - @Autowired | |
| 35 | - DayOfDirectives dayOfDirectives; | |
| 36 | - | |
| 37 | - @Autowired | |
| 38 | - CalcWaybillService calcWaybillService; | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - BudgetService budgetService; | |
| 42 | - | |
| 43 | - @Override | |
| 44 | - public void run() { | |
| 45 | - logger.info("开始计算油量平衡表...."); | |
| 46 | - try{ | |
| 47 | - ylbService.obtainDsq(); | |
| 48 | -// logger.info("开始计算班次准点率...."); | |
| 49 | -// sheetService.saveSheetList(""); | |
| 50 | -// logger.info("计算班次准点率结束!"); | |
| 51 | - } catch(Exception e){ | |
| 52 | - logger.error("计算油量平衡表失败",e); | |
| 53 | - } | |
| 54 | - try{ | |
| 55 | - logger.info("开始计算电量平衡表...."); | |
| 56 | - dlbService.obtainDsq(); | |
| 57 | - } catch(Exception e){ | |
| 58 | - logger.error("计算电量平衡表失败",e); | |
| 59 | - } | |
| 60 | - | |
| 61 | - try{ | |
| 62 | - logger.info("计算路单里程开始"); | |
| 63 | - calcWaybillService.autoGenerate("", ""); | |
| 64 | - }catch(Exception e){ | |
| 65 | - logger.error("计算路单里程失败",e); | |
| 66 | - } | |
| 67 | - | |
| 68 | - logger.info("开始保存统计日报...."); | |
| 69 | - try{ | |
| 70 | - calcWaybillService.calcDaily("", ""); | |
| 71 | - }catch(Exception e){ | |
| 72 | - logger.error("统计日报失败",e); | |
| 73 | - } | |
| 74 | - | |
| 75 | - logger.info("开始获取营收人次...."); | |
| 76 | - try{ | |
| 77 | - budgetService.updateRevenueRange("", ""); | |
| 78 | - }catch(Exception e){ | |
| 79 | - logger.error("获取营收人次失败",e); | |
| 80 | - } | |
| 81 | - | |
| 82 | - //清除指令数据 | |
| 83 | - dayOfDirectives.clearAll(); | |
| 84 | - //清除安全驾驶数据 | |
| 85 | - SafeDrivCenter.clear(); | |
| 86 | - //清除超速缓存数据 | |
| 87 | - OverspeedProcess.clear(); | |
| 88 | - | |
| 89 | - GpsDataLoaderThread.setFlag(0); | |
| 90 | - | |
| 91 | - } | |
| 92 | -} | |
| 1 | +package com.bsth.data.schedule.thread; | |
| 2 | + | |
| 3 | +import com.bsth.data.directive.DayOfDirectives; | |
| 4 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 5 | +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | |
| 6 | +import com.bsth.service.calc.CalcWaybillService; | |
| 7 | +import com.bsth.service.forms.BudgetService; | |
| 8 | +import com.bsth.service.oil.DlbService; | |
| 9 | +import com.bsth.data.safe_driv.SafeDrivCenter; | |
| 10 | +import com.bsth.service.oil.YlbService; | |
| 11 | +import com.bsth.service.report.SheetService; | |
| 12 | + | |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.slf4j.LoggerFactory; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.stereotype.Component; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 计算油、公里加注量 线程 | |
| 20 | + * Created by panzhao on 2017/3/7. | |
| 21 | + */ | |
| 22 | +@Component | |
| 23 | +public class CalcOilThread extends Thread{ | |
| 24 | + | |
| 25 | + @Autowired | |
| 26 | + YlbService ylbService; | |
| 27 | + @Autowired | |
| 28 | + DlbService dlbService; | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + SheetService sheetService; | |
| 32 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 33 | + | |
| 34 | + @Autowired | |
| 35 | + DayOfDirectives dayOfDirectives; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + CalcWaybillService calcWaybillService; | |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + BudgetService budgetService; | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void run() { | |
| 45 | + logger.info("开始计算油量平衡表...."); | |
| 46 | + try{ | |
| 47 | + ylbService.obtainDsq(); | |
| 48 | +// logger.info("开始计算班次准点率...."); | |
| 49 | +// sheetService.saveSheetList(""); | |
| 50 | +// logger.info("计算班次准点率结束!"); | |
| 51 | + } catch(Exception e){ | |
| 52 | + logger.error("计算油量平衡表失败",e); | |
| 53 | + } | |
| 54 | + try{ | |
| 55 | + logger.info("开始计算电量平衡表...."); | |
| 56 | + dlbService.obtainDsq(); | |
| 57 | + } catch(Exception e){ | |
| 58 | + logger.error("计算电量平衡表失败",e); | |
| 59 | + } | |
| 60 | + | |
| 61 | + try{ | |
| 62 | + logger.info("计算路单里程开始"); | |
| 63 | + calcWaybillService.autoGenerate("", ""); | |
| 64 | + }catch(Exception e){ | |
| 65 | + logger.error("计算路单里程失败",e); | |
| 66 | + } | |
| 67 | + | |
| 68 | + logger.info("开始保存统计日报...."); | |
| 69 | + try{ | |
| 70 | + calcWaybillService.calcDaily("", ""); | |
| 71 | + }catch(Exception e){ | |
| 72 | + logger.error("统计日报失败",e); | |
| 73 | + } | |
| 74 | + | |
| 75 | + logger.info("开始获取营收人次...."); | |
| 76 | + try{ | |
| 77 | + budgetService.updateRevenueRange("", ""); | |
| 78 | + }catch(Exception e){ | |
| 79 | + logger.error("获取营收人次失败",e); | |
| 80 | + } | |
| 81 | + | |
| 82 | + //清除指令数据 | |
| 83 | + dayOfDirectives.clearAll(); | |
| 84 | + //清除安全驾驶数据 | |
| 85 | + SafeDrivCenter.clear(); | |
| 86 | + //清除超速缓存数据 | |
| 87 | + OverspeedProcess.clear(); | |
| 88 | + } | |
| 89 | +} | ... | ... |
src/main/java/com/bsth/entity/SystemParam.java
src/main/java/com/bsth/filter/SQLInjectFilter.java
| 1 | 1 | package com.bsth.filter; |
| 2 | 2 | |
| 3 | -import org.springframework.beans.factory.annotation.Value; | |
| 3 | +import com.bsth.data.SystemParamCache; | |
| 4 | 4 | import org.springframework.stereotype.Component; |
| 5 | 5 | |
| 6 | 6 | import javax.servlet.FilterChain; |
| ... | ... | @@ -17,13 +17,10 @@ public class SQLInjectFilter extends BaseFilter{ |
| 17 | 17 | |
| 18 | 18 | private final static String specialUri = "adminUtils"; |
| 19 | 19 | |
| 20 | - @Value("${enabled.sqlinject}") | |
| 21 | - private boolean sqlInjectEnabled; | |
| 22 | - | |
| 23 | 20 | @Override |
| 24 | 21 | public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) |
| 25 | 22 | throws IOException, ServletException { |
| 26 | - if (!sqlInjectEnabled) { | |
| 23 | + if (!SystemParamCache.getEnabledFilterSqlInjection()) { | |
| 27 | 24 | chain.doFilter(request, response); |
| 28 | 25 | return; |
| 29 | 26 | } |
| ... | ... | @@ -69,12 +66,4 @@ public class SQLInjectFilter extends BaseFilter{ |
| 69 | 66 | public static void setInjStr(String injStr) { |
| 70 | 67 | SQLInjectFilter.injStr = injStr; |
| 71 | 68 | } |
| 72 | - | |
| 73 | - public boolean isSqlInjectEnabled() { | |
| 74 | - return sqlInjectEnabled; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public void setSqlInjectEnabled(boolean sqlInjectEnabled) { | |
| 78 | - this.sqlInjectEnabled = sqlInjectEnabled; | |
| 79 | - } | |
| 80 | 69 | } | ... | ... |
src/main/java/com/bsth/security/SsoConfig.java
| ... | ... | @@ -55,7 +55,6 @@ public class SsoConfig { |
| 55 | 55 | return systemCode; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - @Value("${sso.systemcode}") | |
| 59 | 58 | public void setSystemCode(String systemCode) { |
| 60 | 59 | this.systemCode = systemCode; |
| 61 | 60 | } |
| ... | ... | @@ -85,7 +84,6 @@ public class SsoConfig { |
| 85 | 84 | return ssoAuthUrl; |
| 86 | 85 | } |
| 87 | 86 | |
| 88 | - @Value("${sso.http.url.auth}") | |
| 89 | 87 | public void setSsoAuthUrl(String ssoAuthUrl) { |
| 90 | 88 | this.ssoAuthUrl = ssoAuthUrl; |
| 91 | 89 | } | ... | ... |
src/main/java/com/bsth/service/SystemParamService.java
src/main/java/com/bsth/service/forms/impl/RevenueLoader.java
| 1 | -package com.bsth.service.forms.impl; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.bsth.util.ConfigUtil; | |
| 5 | -import org.apache.http.HttpEntity; | |
| 6 | -import org.apache.http.client.config.RequestConfig; | |
| 7 | -import org.apache.http.client.methods.CloseableHttpResponse; | |
| 8 | -import org.apache.http.client.methods.HttpGet; | |
| 9 | -import org.apache.http.impl.client.CloseableHttpClient; | |
| 10 | -import org.apache.http.impl.client.HttpClients; | |
| 11 | -import org.slf4j.Logger; | |
| 12 | -import org.slf4j.LoggerFactory; | |
| 13 | -import org.springframework.stereotype.Component; | |
| 14 | - | |
| 15 | -import java.io.BufferedReader; | |
| 16 | -import java.io.InputStreamReader; | |
| 17 | -import java.util.ArrayList; | |
| 18 | -import java.util.List; | |
| 19 | -import java.util.Map; | |
| 20 | - | |
| 21 | -@Component | |
| 22 | -public class RevenueLoader { | |
| 23 | - | |
| 24 | - static Logger logger = LoggerFactory.getLogger(RevenueLoader.class); | |
| 25 | - | |
| 26 | - static String url; | |
| 27 | - static List<Map<String, Object>> list; | |
| 28 | - static CloseableHttpClient httpClient = null; | |
| 29 | - static HttpGet get; | |
| 30 | - static RequestConfig requestConfig; | |
| 31 | - static CloseableHttpResponse response; | |
| 32 | - static HttpEntity entity; | |
| 33 | - static BufferedReader br; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 从票务系统获取营收 | |
| 37 | - * @param date | |
| 38 | - * @param gsBm | |
| 39 | - * @return | |
| 40 | - */ | |
| 41 | - public static List<Map<String, Object>> load(String date, String gsBm){ | |
| 42 | - try { | |
| 43 | - url = ConfigUtil.get("http.ticketing.interface") + "?txnType=getLineRevenue&busiDate="+date+"&companyCode="+gsBm; | |
| 44 | - list = new ArrayList<>(); | |
| 45 | - httpClient = HttpClients.createDefault(); | |
| 46 | - get = new HttpGet(url); | |
| 47 | - requestConfig = RequestConfig.custom() | |
| 48 | - .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | |
| 49 | - .setSocketTimeout(2500).build(); | |
| 50 | - get.setConfig(requestConfig); | |
| 51 | - if(list.size() > 0) | |
| 52 | - list.clear(); | |
| 53 | - logger.info("load start..."); | |
| 54 | - response = httpClient.execute(get); | |
| 55 | - entity = response.getEntity(); | |
| 56 | - if(null == entity) | |
| 57 | - return list; | |
| 58 | - | |
| 59 | - br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 60 | - StringBuilder sb = new StringBuilder(); | |
| 61 | - String str; | |
| 62 | - while ((str = br.readLine()) != null) | |
| 63 | - sb.append(str); | |
| 64 | - | |
| 65 | - Map<String, Object> parseObj = JSON.parseObject(sb.toString(), Map.class); | |
| 66 | - if(parseObj.get("status") != null && "SUCCESS".equals(parseObj.get("status").toString())){ | |
| 67 | - for(Map<String, Object> m : (List<Map<String, Object>>) parseObj.get("respData")){ | |
| 68 | - list.add(m); | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - logger.info("load end ! size: " + list.size()); | |
| 73 | - | |
| 74 | - if (null != response) | |
| 75 | - response.close(); | |
| 76 | - } catch (Exception e) { | |
| 77 | - logger.error("", e); | |
| 78 | - } | |
| 79 | - | |
| 80 | - return list; | |
| 81 | - } | |
| 82 | -} | |
| 1 | +package com.bsth.service.forms.impl; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.bsth.data.SystemParamCache; | |
| 5 | +import org.apache.http.HttpEntity; | |
| 6 | +import org.apache.http.client.config.RequestConfig; | |
| 7 | +import org.apache.http.client.methods.CloseableHttpResponse; | |
| 8 | +import org.apache.http.client.methods.HttpGet; | |
| 9 | +import org.apache.http.impl.client.CloseableHttpClient; | |
| 10 | +import org.apache.http.impl.client.HttpClients; | |
| 11 | +import org.slf4j.Logger; | |
| 12 | +import org.slf4j.LoggerFactory; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | + | |
| 15 | +import java.io.BufferedReader; | |
| 16 | +import java.io.InputStreamReader; | |
| 17 | +import java.util.ArrayList; | |
| 18 | +import java.util.List; | |
| 19 | +import java.util.Map; | |
| 20 | + | |
| 21 | +@Component | |
| 22 | +public class RevenueLoader { | |
| 23 | + | |
| 24 | + static Logger logger = LoggerFactory.getLogger(RevenueLoader.class); | |
| 25 | + | |
| 26 | + static String url; | |
| 27 | + static List<Map<String, Object>> list; | |
| 28 | + static CloseableHttpClient httpClient = null; | |
| 29 | + static HttpGet get; | |
| 30 | + static RequestConfig requestConfig; | |
| 31 | + static CloseableHttpResponse response; | |
| 32 | + static HttpEntity entity; | |
| 33 | + static BufferedReader br; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 从票务系统获取营收 | |
| 37 | + * @param date | |
| 38 | + * @param gsBm | |
| 39 | + * @return | |
| 40 | + */ | |
| 41 | + public static List<Map<String, Object>> load(String date, String gsBm){ | |
| 42 | + try { | |
| 43 | + url = String.format(SystemParamCache.getUrlHttpTicketing(), date, gsBm); | |
| 44 | + list = new ArrayList<>(); | |
| 45 | + httpClient = HttpClients.createDefault(); | |
| 46 | + get = new HttpGet(url); | |
| 47 | + requestConfig = RequestConfig.custom() | |
| 48 | + .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | |
| 49 | + .setSocketTimeout(2500).build(); | |
| 50 | + get.setConfig(requestConfig); | |
| 51 | + if(list.size() > 0) | |
| 52 | + list.clear(); | |
| 53 | + logger.info("load start..."); | |
| 54 | + response = httpClient.execute(get); | |
| 55 | + entity = response.getEntity(); | |
| 56 | + if(null == entity) | |
| 57 | + return list; | |
| 58 | + | |
| 59 | + br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
| 60 | + StringBuilder sb = new StringBuilder(); | |
| 61 | + String str; | |
| 62 | + while ((str = br.readLine()) != null) | |
| 63 | + sb.append(str); | |
| 64 | + | |
| 65 | + Map<String, Object> parseObj = JSON.parseObject(sb.toString(), Map.class); | |
| 66 | + if(parseObj.get("status") != null && "SUCCESS".equals(parseObj.get("status").toString())){ | |
| 67 | + for(Map<String, Object> m : (List<Map<String, Object>>) parseObj.get("respData")){ | |
| 68 | + list.add(m); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + logger.info("load end ! size: " + list.size()); | |
| 73 | + | |
| 74 | + if (null != response) | |
| 75 | + response.close(); | |
| 76 | + } catch (Exception e) { | |
| 77 | + logger.error("", e); | |
| 78 | + } | |
| 79 | + | |
| 80 | + return list; | |
| 81 | + } | |
| 82 | +} | ... | ... |
src/main/java/com/bsth/service/impl/SystemParamServiceImpl.java
| 1 | 1 | package com.bsth.service.impl; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.SystemParam; |
| 4 | +import com.bsth.repository.SystemParamRepository; | |
| 4 | 5 | import com.bsth.service.SystemParamService; |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
| 8 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 9 | +import org.springframework.stereotype.Service; | |
| 10 | + | |
| 11 | +import java.util.HashMap; | |
| 12 | +import java.util.Map; | |
| 5 | 13 | |
| 6 | 14 | /** |
| 7 | 15 | * @author Hill |
| 8 | 16 | */ |
| 17 | +@Service | |
| 18 | +@EnableScheduling | |
| 9 | 19 | public class SystemParamServiceImpl extends BaseServiceImpl<SystemParam, Integer> implements SystemParamService { |
| 20 | + | |
| 21 | + @Autowired | |
| 22 | + private SystemParamRepository systemParamRepository; | |
| 23 | + | |
| 24 | + private Map<String, String> pairs = new HashMap<>(); | |
| 25 | + | |
| 26 | + @Scheduled(cron = "0 0/30 * * * ?") | |
| 27 | + public void refresh() { | |
| 28 | + for (SystemParam sp : systemParamRepository.findAll()) { | |
| 29 | + pairs.put(sp.getKey(), sp.getValue()); | |
| 30 | + } | |
| 31 | + } | |
| 32 | + | |
| 33 | + public String getValue(String key) { | |
| 34 | + return pairs.get(key); | |
| 35 | + } | |
| 10 | 36 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -6,7 +6,6 @@ import java.math.BigDecimal; |
| 6 | 6 | import java.net.HttpURLConnection; |
| 7 | 7 | import java.net.MalformedURLException; |
| 8 | 8 | import java.net.URL; |
| 9 | -import java.net.URLEncoder; | |
| 10 | 9 | import java.sql.ResultSet; |
| 11 | 10 | import java.sql.SQLException; |
| 12 | 11 | import java.text.DecimalFormat; |
| ... | ... | @@ -29,6 +28,7 @@ import java.util.Set; |
| 29 | 28 | import java.util.concurrent.*; |
| 30 | 29 | import java.util.regex.Pattern; |
| 31 | 30 | |
| 31 | +import com.bsth.data.SystemParamCache; | |
| 32 | 32 | import org.apache.commons.io.IOUtils; |
| 33 | 33 | import org.apache.commons.lang3.StringEscapeUtils; |
| 34 | 34 | import org.apache.commons.lang3.StringUtils; |
| ... | ... | @@ -121,7 +121,6 @@ import com.bsth.util.Arith; |
| 121 | 121 | import com.bsth.util.ComparableChild; |
| 122 | 122 | import com.bsth.util.ComparableLp; |
| 123 | 123 | import com.bsth.util.ComparableReal; |
| 124 | -import com.bsth.util.ConfigUtil; | |
| 125 | 124 | import com.bsth.util.DateUtils; |
| 126 | 125 | import com.bsth.util.ReportRelatedUtils; |
| 127 | 126 | import com.bsth.util.ReportUtils; |
| ... | ... | @@ -135,8 +134,6 @@ import com.github.stuxuhai.jpinyin.PinyinHelper; |
| 135 | 134 | import com.google.common.base.Splitter; |
| 136 | 135 | import com.google.common.collect.Lists; |
| 137 | 136 | |
| 138 | -import javax.ws.rs.HEAD; | |
| 139 | - | |
| 140 | 137 | @Service |
| 141 | 138 | public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> |
| 142 | 139 | implements ScheduleRealInfoService, InitializingBean, DisposableBean { |
| ... | ... | @@ -225,6 +222,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 225 | 222 | |
| 226 | 223 | @Autowired |
| 227 | 224 | RepairReportRepository repairReportRepository; |
| 225 | + | |
| 228 | 226 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 229 | 227 | |
| 230 | 228 | SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), |
| ... | ... | @@ -6679,7 +6677,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 6679 | 6677 | // 分公司保存格式 分公司编码_公司编码 |
| 6680 | 6678 | String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode); |
| 6681 | 6679 | String[] arr = val.split("_"); |
| 6682 | - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1])); | |
| 6680 | + StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpReport(arr[1])); | |
| 6683 | 6681 | url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]); |
| 6684 | 6682 | |
| 6685 | 6683 | int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0); |
| ... | ... | @@ -6719,7 +6717,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 6719 | 6717 | // 分公司保存格式 分公司编码_公司编码 |
| 6720 | 6718 | String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode()); |
| 6721 | 6719 | String[] arr = val.split("_"); |
| 6722 | - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1])); | |
| 6720 | + StringBuilder url = new StringBuilder(SystemParamCache.getUrlHttpReport(arr[1])); | |
| 6723 | 6721 | url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]); |
| 6724 | 6722 | |
| 6725 | 6723 | Map<String, Object> res = request(url.toString()); | ... | ... |
src/main/java/com/bsth/util/MailUtils.java
| 1 | 1 | package com.bsth.util; |
| 2 | 2 | |
| 3 | +import com.bsth.data.SystemParamCache; | |
| 3 | 4 | import com.bsth.email.SimpleMailSender; |
| 4 | 5 | import com.bsth.email.entity.EmailBean; |
| 5 | -import org.springframework.beans.factory.annotation.Value; | |
| 6 | 6 | import org.springframework.stereotype.Component; |
| 7 | 7 | |
| 8 | 8 | import java.util.List; |
| ... | ... | @@ -13,21 +13,10 @@ import java.util.List; |
| 13 | 13 | @Component |
| 14 | 14 | public class MailUtils { |
| 15 | 15 | |
| 16 | - @Value("${admin.mail}") | |
| 17 | - private String emailSendToAddress; | |
| 18 | - | |
| 19 | 16 | private Tools tools = new Tools("mailbox.properties"); |
| 20 | 17 | |
| 21 | 18 | private SimpleMailSender sms = new SimpleMailSender(tools.getValue("username"),tools.getValue("password")); |
| 22 | 19 | |
| 23 | - public String getEmailSendToAddress() { | |
| 24 | - return emailSendToAddress; | |
| 25 | - } | |
| 26 | - | |
| 27 | - public void setEmailSendToAddress(String emailSendToAddress) { | |
| 28 | - this.emailSendToAddress = emailSendToAddress; | |
| 29 | - } | |
| 30 | - | |
| 31 | 20 | /** |
| 32 | 21 | * recipients |
| 33 | 22 | * 收件人集合 |
| ... | ... | @@ -52,9 +41,9 @@ public class MailUtils { |
| 52 | 41 | |
| 53 | 42 | * 邮件 |
| 54 | 43 | */ |
| 55 | - public int sendMail(String recipient,EmailBean mail){ | |
| 44 | + public int sendMail(String recipient, EmailBean mail){ | |
| 56 | 45 | try { |
| 57 | - sms.send(recipient, mail.getSubject(),mail.getContent()); | |
| 46 | + sms.send(recipient, mail.getSubject(), mail.getContent()); | |
| 58 | 47 | } catch (Exception e) { |
| 59 | 48 | e.printStackTrace(); |
| 60 | 49 | return -1; |
| ... | ... | @@ -63,6 +52,6 @@ public class MailUtils { |
| 63 | 52 | } |
| 64 | 53 | |
| 65 | 54 | public int sendMail(EmailBean mail){ |
| 66 | - return sendMail(emailSendToAddress, mail); | |
| 55 | + return sendMail(SystemParamCache.getMailAdmin(), mail); | |
| 67 | 56 | } |
| 68 | 57 | } | ... | ... |
src/main/resources/application-dev.properties
| ... | ... | @@ -38,25 +38,6 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 38 | 38 | spring.datasource.hikari.validation-timeout= 3000 |
| 39 | 39 | spring.datasource.hikari.register-mbeans=true |
| 40 | 40 | |
| 41 | -## gps client data | |
| 42 | -http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all | |
| 43 | -## gateway real data | |
| 44 | -http.gps.real.url= http://114.80.178.12:18080/transport_server/rtgps/ | |
| 45 | -## gateway send directive | |
| 46 | -http.send.directive = http://192.168.168.201:9090/transport_server/message/ | |
| 47 | -## rfid data | |
| 48 | -http.rfid.url= http://114.80.178.12:29000/rfid | |
| 49 | -## http ticketing interface | |
| 50 | -http.ticketing.interface= http://112.64.187.3:1080/gjService/request | |
| 51 | -## first last generate | |
| 52 | -ms.fl.generate=true | |
| 53 | -## dsm ack interface | |
| 54 | -dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | |
| 55 | -## cp ack interface | |
| 56 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | |
| 57 | -## admin mail | |
| 58 | -admin.mail= 3090342880@qq.com | |
| 59 | - | |
| 60 | 41 | sso.enabled= true |
| 61 | 42 | sso.systemcode = SYSUS023 |
| 62 | 43 | sso.http.url.login= http://10.10.200.142:9112/login?redirect=%2Findex | ... | ... |
src/main/resources/application-prod.properties
| ... | ... | @@ -31,36 +31,6 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 31 | 31 | spring.datasource.hikari.validation-timeout= 3000 |
| 32 | 32 | spring.datasource.hikari.register-mbeans=true |
| 33 | 33 | |
| 34 | -## gps client data | |
| 35 | -http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all | |
| 36 | -## gateway real data | |
| 37 | -http.gps.real.url= http://10.10.150.103:8080/transport_server/rtgps/ | |
| 38 | -## gateway send directive | |
| 39 | -http.send.directive= http://10.10.150.103:8080/transport_server/message/ | |
| 40 | -## rfid data | |
| 41 | -http.rfid.url= http://10.10.150.103:9000/rfid | |
| 42 | -## wxsb | |
| 43 | -#http.report.url.05= http://192.168.168.154:8088/ygjwsystem_j2ee/clbx/clbx_dd.do | |
| 44 | -#http.report.url.22= http://192.168.168.154:8088/jgjwsystem_j2ee/clbx/clbx_dd.do | |
| 45 | -#http.report.url.26= http://192.168.168.154:8088/nhjwsystem_j2ee/clbx/clbx_dd.do | |
| 46 | -#http.report.url.55= http://192.168.168.154:8088/snjwsystem_j2ee/clbx/clbx_dd.do | |
| 47 | -http.report.url.05= http://116.228.197.222:8081/ygjwsystem_j2ee/clbx/clbx_dd.do | |
| 48 | -http.report.url.22= http://116.247.73.122:9098/jgjwsystem_j2ee/clbx/clbx_dd.do | |
| 49 | -http.report.url.26= http://116.236.141.34:8088/nhjwsystem_j2ee/clbx/clbx_dd.do | |
| 50 | -http.report.url.55= http://180.168.216.248:8088/snjwsystem_j2ee/clbx/clbx_dd.do | |
| 51 | -## http ticketing interface | |
| 52 | -http.ticketing.interface= http://112.64.187.3:1080/gjService/request | |
| 53 | -## first last generate | |
| 54 | -ms.fl.generate=true | |
| 55 | -## dsm ack interface | |
| 56 | -dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | |
| 57 | -## cp ack interface | |
| 58 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | |
| 59 | -## admin mail | |
| 60 | -admin.mail= 3090342880@qq.com | |
| 61 | -## enabled | |
| 62 | -enabled.sqlinject= false | |
| 63 | - | |
| 64 | 34 | sso.enabled= true |
| 65 | 35 | sso.systemcode = SYSUS023 |
| 66 | 36 | sso.http.url.login= http://10.10.200.142:9112/login?redirect=%2Findex | ... | ... |
src/main/resources/application-test.properties
| ... | ... | @@ -31,36 +31,6 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 31 | 31 | spring.datasource.hikari.validation-timeout= 3000 |
| 32 | 32 | spring.datasource.hikari.register-mbeans=true |
| 33 | 33 | |
| 34 | -## gps client data | |
| 35 | -http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all | |
| 36 | -## gateway real data | |
| 37 | -http.gps.real.url= http://10.10.150.103:8080/transport_server/rtgps/ | |
| 38 | -## gateway send directive | |
| 39 | -#http.send.directive= http://10.10.150.103:8080/transport_server/message/ | |
| 40 | -## rfid data | |
| 41 | -http.rfid.url= http://114.80.178.12:29000/rfid | |
| 42 | -## wxsb | |
| 43 | -#http.report.url.05= http://192.168.168.154:8088/ygjwsystem_j2ee/clbx/clbx_dd.do | |
| 44 | -#http.report.url.22= http://192.168.168.154:8088/jgjwsystem_j2ee/clbx/clbx_dd.do | |
| 45 | -#http.report.url.26= http://192.168.168.154:8088/nhjwsystem_j2ee/clbx/clbx_dd.do | |
| 46 | -#http.report.url.55= http://192.168.168.154:8088/snjwsystem_j2ee/clbx/clbx_dd.do | |
| 47 | -http.report.url.05= http://116.228.197.222:8081/ygjwsystem_j2ee/clbx/clbx_dd.do | |
| 48 | -http.report.url.22= http://116.247.73.122:9098/jgjwsystem_j2ee/clbx/clbx_dd.do | |
| 49 | -http.report.url.26= http://116.236.141.34:8088/nhjwsystem_j2ee/clbx/clbx_dd.do | |
| 50 | -http.report.url.55= http://180.168.216.248:8088/snjwsystem_j2ee/clbx/clbx_dd.do | |
| 51 | -## http ticketing interface | |
| 52 | -http.ticketing.interface= http://112.64.187.3:1080/gjService/request | |
| 53 | -## first last generate | |
| 54 | -ms.fl.generate=false | |
| 55 | -## dsm ack interface | |
| 56 | -dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | |
| 57 | -## cp ack interface | |
| 58 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | |
| 59 | -## admin mail | |
| 60 | -admin.mail= 3090342880@qq.com | |
| 61 | -## enabled | |
| 62 | -enabled.sqlinject= false | |
| 63 | - | |
| 64 | 34 | sso.enabled= true |
| 65 | 35 | sso.systemcode = SYSUS023 |
| 66 | 36 | sso.http.url.login= http://10.10.200.142:9112/login?redirect=%2Findex | ... | ... |
src/main/resources/ms-jdbc.properties
| ... | ... | @@ -6,4 +6,4 @@ |
| 6 | 6 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | 7 | ms.mysql.url= jdbc:mysql://10.10.150.103/ms?useUnicode=true&characterEncoding=utf-8 |
| 8 | 8 | ms.mysql.username= root |
| 9 | -ms.mysql.password= Aa123456 | |
| 10 | 9 | \ No newline at end of file |
| 10 | +ms.mysql.password= fsodlgjiuigAQF2$9fs9 | |
| 11 | 11 | \ No newline at end of file | ... | ... |
src/main/resources/traffic-jdbc.properties
| ... | ... | @@ -6,4 +6,4 @@ |
| 6 | 6 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | 7 | ms.mysql.url= jdbc:mysql://10.10.150.103/ms?useUnicode=true&characterEncoding=utf-8 |
| 8 | 8 | ms.mysql.username= root |
| 9 | -ms.mysql.password= Aa123456 | |
| 10 | 9 | \ No newline at end of file |
| 10 | +ms.mysql.password= fsodlgjiuigAQF2$9fs9 | |
| 11 | 11 | \ No newline at end of file | ... | ... |