Commit 6818c917c5fd4b12dc29f43f50c387b9badeb078
1 parent
1b325dff
1.加入IP白名单限制
Showing
7 changed files
with
593 additions
and
336 deletions
src/main/java/com/bsth/XDApplication.java
| 1 | -package com.bsth; | |
| 2 | - | |
| 3 | -import com.bsth.data.BasicData; | |
| 4 | -import com.bsth.data.LineVersionsData; | |
| 5 | -import com.bsth.data.ThreadMonotor; | |
| 6 | -import com.bsth.data.car_out_info.UpdateDBThread; | |
| 7 | -import com.bsth.data.directive.DirectivesPstThread; | |
| 8 | -import com.bsth.data.forecast.SampleTimeDataLoader; | |
| 9 | -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | |
| 10 | -import com.bsth.data.gpsdata_v2.thread.OfflineMonitorThread; | |
| 11 | -import com.bsth.data.msg_queue.DirectivePushQueue; | |
| 12 | -import com.bsth.data.msg_queue.WebSocketPushQueue; | |
| 13 | -import com.bsth.data.safe_driv.SafeDrivDataLoadThread; | |
| 14 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 15 | -import com.bsth.data.schedule.auto_exec.AutoExecScanThread; | |
| 16 | -import com.bsth.data.schedule.e_state_check.thread.FixedCheckStationCodeThread; | |
| 17 | -import com.bsth.data.schedule.edit_logs.SeiPstThread; | |
| 18 | -import com.bsth.data.schedule.late_adjust.ScheduleLateThread; | |
| 19 | -import com.bsth.data.schedule.signal.SchSiginUpdateDBThread; | |
| 20 | -import com.bsth.data.schedule.thread.CalcOilThread; | |
| 21 | -import com.bsth.data.schedule.thread.SchedulePstThread; | |
| 22 | -import com.bsth.data.schedule.thread.ScheduleRefreshThread; | |
| 23 | -import com.bsth.data.schedule.thread.SubmitToTrafficManage; | |
| 24 | -import com.bsth.util.DateUtils; | |
| 25 | -import com.bsth.util.Tools; | |
| 26 | -import org.slf4j.Logger; | |
| 27 | -import org.slf4j.LoggerFactory; | |
| 28 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 29 | -import org.springframework.boot.CommandLineRunner; | |
| 30 | -import org.springframework.stereotype.Component; | |
| 31 | - | |
| 32 | -import java.util.concurrent.ScheduledExecutorService; | |
| 33 | -import java.util.concurrent.TimeUnit; | |
| 34 | - | |
| 35 | -/** | |
| 36 | - * 线调大部分服务都在这里启动 | |
| 37 | - * Created by panzhao on 2017/5/14. | |
| 38 | - */ | |
| 39 | -@Component | |
| 40 | -public class XDApplication implements CommandLineRunner { | |
| 41 | - | |
| 42 | - Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 43 | - | |
| 44 | - @Autowired | |
| 45 | - BasicData.BasicDataLoader basicDataLoader; | |
| 46 | - @Autowired | |
| 47 | - UpdateDBThread fcxxUpdateThread; | |
| 48 | - @Autowired | |
| 49 | - ScheduleRefreshThread scheduleRefreshThread; | |
| 50 | - @Autowired | |
| 51 | - SchedulePstThread schedulePstThread; | |
| 52 | - @Autowired | |
| 53 | - ScheduleLateThread scheduleLateThread; | |
| 54 | - @Autowired | |
| 55 | - SubmitToTrafficManage submitToTrafficManage; | |
| 56 | - @Autowired | |
| 57 | - CalcOilThread calcOilThread; | |
| 58 | - @Autowired | |
| 59 | - DirectivesPstThread directivesPstThread; | |
| 60 | - @Autowired | |
| 61 | - ThreadMonotor threadMonotor; | |
| 62 | - @Autowired | |
| 63 | - SeiPstThread seiPstThread; | |
| 64 | - @Autowired | |
| 65 | - SampleTimeDataLoader sampleTimeDataLoader; | |
| 66 | - @Autowired | |
| 67 | - SchSiginUpdateDBThread schSiginUpdateDBThread; | |
| 68 | - @Autowired | |
| 69 | - AutoExecScanThread autoExecScanThread; | |
| 70 | - | |
| 71 | - @Autowired | |
| 72 | - GpsDataLoaderThread gpsDataLoader; | |
| 73 | - | |
| 74 | - @Autowired | |
| 75 | - OfflineMonitorThread offlineMonitorThread; | |
| 76 | - | |
| 77 | - @Autowired | |
| 78 | - LineVersionsData lineVersionsData; | |
| 79 | - | |
| 80 | - /*@Autowired | |
| 81 | - FixedEnableVerionsThread fixedEnableVerionsThread;*/ | |
| 82 | - | |
| 83 | - @Autowired | |
| 84 | - SafeDrivDataLoadThread safeDrivDataLoadThread; | |
| 85 | - | |
| 86 | - @Autowired | |
| 87 | - FixedCheckStationCodeThread fixedCheckStationCodeThread; | |
| 88 | - | |
| 89 | - private static long timeDiff; | |
| 90 | - private static long timeDiffTraffic; | |
| 91 | - | |
| 92 | - static { | |
| 93 | - // 早上2:20 | |
| 94 | - timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis(); | |
| 95 | - if (timeDiff < 0) | |
| 96 | - timeDiff += (1000 * 60 * 60 * 24); | |
| 97 | - // 早上07:00 | |
| 98 | - timeDiffTraffic = (DateUtils.getTimestamp() + 1000 * 60 * 60 * 7) - System.currentTimeMillis(); | |
| 99 | - if (timeDiffTraffic < 0) | |
| 100 | - timeDiffTraffic += (1000 * 60 * 60 * 24); | |
| 101 | - } | |
| 102 | - | |
| 103 | - @Override | |
| 104 | - public void run(String... strings) throws Exception { | |
| 105 | - try { | |
| 106 | - Tools tools = new Tools("application.properties"); | |
| 107 | - String environment = tools.getValue("spring.profiles.active"); | |
| 108 | - //预先加载基础的对照数据 | |
| 109 | - basicDataLoader.loadAllData(); | |
| 110 | - switch (environment){ | |
| 111 | - case "dev": | |
| 112 | - devInit(); | |
| 113 | - break; | |
| 114 | - case "prod": | |
| 115 | - prodInit(); | |
| 116 | - break; | |
| 117 | - } | |
| 118 | - }catch (Exception e){ | |
| 119 | - log.error("线调后台启动出现异常!!", e); | |
| 120 | - System.exit(1); | |
| 121 | - } | |
| 122 | - } | |
| 123 | - | |
| 124 | - @Autowired | |
| 125 | - DayOfSchedule dayOfSchedule; | |
| 126 | - public void devInit(){ | |
| 127 | - log.info("devInit..."); | |
| 128 | - ScheduledExecutorService sexec = Application.mainServices; | |
| 129 | - //抓取GPS数据 | |
| 130 | - GpsDataLoaderThread.setFlag(-1); | |
| 131 | - //dayOfSchedule.dataRecovery(); | |
| 132 | - //sexec.scheduleWithFixedDelay(gpsDataLoader, 60, 4, TimeUnit.SECONDS); | |
| 133 | - //实际排班更新线程 | |
| 134 | - //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); | |
| 135 | - //sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 30, TimeUnit.SECONDS);//检查班次误点 | |
| 136 | - //sexec.scheduleWithFixedDelay(autoExecScanThread, 100, 50, TimeUnit.SECONDS);//班次自动执行 | |
| 137 | - //WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | |
| 138 | - | |
| 139 | - //sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 50, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码 | |
| 140 | - //实际排班延迟入库线程 | |
| 141 | - //sexec.scheduleWithFixedDelay(schedulePstThread, 60, 15, TimeUnit.SECONDS); | |
| 142 | - //班次修正日志延迟入库 | |
| 143 | - //sexec.scheduleWithFixedDelay(seiPstThread, 60, 30, TimeUnit.SECONDS); | |
| 144 | - //调度指令延迟入库 | |
| 145 | - //sexec.scheduleWithFixedDelay(directivesPstThread, 180, 180, TimeUnit.SECONDS); | |
| 146 | - //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | |
| 147 | - //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS); | |
| 148 | - | |
| 149 | - //安全驾驶 | |
| 150 | - //sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 40, 30, TimeUnit.SECONDS); | |
| 151 | - | |
| 152 | - //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 20, 60 * 2 , TimeUnit.SECONDS); | |
| 153 | - } | |
| 154 | - | |
| 155 | - public void prodInit(){ | |
| 156 | - log.info("prodInit..."); | |
| 157 | - ScheduledExecutorService sexec = Application.mainServices; | |
| 158 | - //安全驾驶 | |
| 159 | - //sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 160 | - | |
| 161 | - /** 线调业务 */ | |
| 162 | - sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 | |
| 163 | - sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 20, TimeUnit.SECONDS);//检查班次误点 | |
| 164 | - GpsDataLoaderThread.setFlag(-1); | |
| 165 | - sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据 | |
| 166 | - sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 60, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码 | |
| 167 | - | |
| 168 | - sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线 | |
| 169 | - sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程 | |
| 170 | - sexec.scheduleWithFixedDelay(seiPstThread, 180, 60, TimeUnit.SECONDS);//班次修正日志入库 | |
| 171 | - sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS);//调度指令延迟入库 | |
| 172 | - //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | |
| 173 | - sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据 | |
| 174 | - sexec.scheduleWithFixedDelay(basicDataLoader, 1, 1, TimeUnit.HOURS);//基础数据更新 | |
| 175 | - sexec.scheduleWithFixedDelay(autoExecScanThread, 180, 50, TimeUnit.SECONDS);//班次自动执行 | |
| 176 | - DirectivePushQueue.start();//消息队列 -指令,系统下发的 | |
| 177 | - WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | |
| 178 | - | |
| 179 | - /** 线调为其他程序提供的数据 --写入数据库 */ | |
| 180 | - sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布) | |
| 181 | - //线路首末班数据(网关用,班次更新时写入) | |
| 182 | - //com.bsth.data.schedule.f_a_l.FirstAndLastHandler | |
| 183 | - sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) | |
| 184 | - | |
| 185 | - //运管处静态数据提交 | |
| 186 | - log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); | |
| 187 | - sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 188 | - //计算油、公里加注 | |
| 189 | - sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 190 | - | |
| 191 | - //线路版本更新 | |
| 192 | - sexec.scheduleWithFixedDelay(lineVersionsData, 60 * 5, 60 * 15, TimeUnit.SECONDS); | |
| 193 | - | |
| 194 | - //线路版本更新 | |
| 195 | - //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS); | |
| 196 | - } | |
| 197 | -} | |
| 1 | +package com.bsth; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.data.LineVersionsData; | |
| 5 | +import com.bsth.data.ThreadMonotor; | |
| 6 | +import com.bsth.data.car_out_info.UpdateDBThread; | |
| 7 | +import com.bsth.data.directive.DirectivesPstThread; | |
| 8 | +import com.bsth.data.forecast.SampleTimeDataLoader; | |
| 9 | +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | |
| 10 | +import com.bsth.data.gpsdata_v2.thread.OfflineMonitorThread; | |
| 11 | +import com.bsth.data.msg_queue.DirectivePushQueue; | |
| 12 | +import com.bsth.data.msg_queue.WebSocketPushQueue; | |
| 13 | +import com.bsth.data.safe_driv.SafeDrivDataLoadThread; | |
| 14 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 15 | +import com.bsth.data.schedule.auto_exec.AutoExecScanThread; | |
| 16 | +import com.bsth.data.schedule.e_state_check.thread.FixedCheckStationCodeThread; | |
| 17 | +import com.bsth.data.schedule.edit_logs.SeiPstThread; | |
| 18 | +import com.bsth.data.schedule.late_adjust.ScheduleLateThread; | |
| 19 | +import com.bsth.data.schedule.signal.SchSiginUpdateDBThread; | |
| 20 | +import com.bsth.data.schedule.thread.CalcOilThread; | |
| 21 | +import com.bsth.data.schedule.thread.SchedulePstThread; | |
| 22 | +import com.bsth.data.schedule.thread.ScheduleRefreshThread; | |
| 23 | +import com.bsth.data.schedule.thread.SubmitToTrafficManage; | |
| 24 | +import com.bsth.util.DateUtils; | |
| 25 | +import com.bsth.util.Tools; | |
| 26 | +import org.slf4j.Logger; | |
| 27 | +import org.slf4j.LoggerFactory; | |
| 28 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 29 | +import org.springframework.boot.CommandLineRunner; | |
| 30 | +import org.springframework.stereotype.Component; | |
| 31 | + | |
| 32 | +import java.util.concurrent.ScheduledExecutorService; | |
| 33 | +import java.util.concurrent.TimeUnit; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * 线调大部分服务都在这里启动 | |
| 37 | + * Created by panzhao on 2017/5/14. | |
| 38 | + */ | |
| 39 | +@Component | |
| 40 | +public class XDApplication implements CommandLineRunner { | |
| 41 | + | |
| 42 | + Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 43 | + | |
| 44 | + @Autowired | |
| 45 | + BasicData.BasicDataLoader basicDataLoader; | |
| 46 | + | |
| 47 | + @Autowired | |
| 48 | + BasicData.WhiteIpDataLoader whiteIpDataLoader; | |
| 49 | + | |
| 50 | + @Autowired | |
| 51 | + UpdateDBThread fcxxUpdateThread; | |
| 52 | + | |
| 53 | + @Autowired | |
| 54 | + ScheduleRefreshThread scheduleRefreshThread; | |
| 55 | + | |
| 56 | + @Autowired | |
| 57 | + SchedulePstThread schedulePstThread; | |
| 58 | + | |
| 59 | + @Autowired | |
| 60 | + ScheduleLateThread scheduleLateThread; | |
| 61 | + | |
| 62 | + @Autowired | |
| 63 | + SubmitToTrafficManage submitToTrafficManage; | |
| 64 | + | |
| 65 | + @Autowired | |
| 66 | + CalcOilThread calcOilThread; | |
| 67 | + | |
| 68 | + @Autowired | |
| 69 | + DirectivesPstThread directivesPstThread; | |
| 70 | + | |
| 71 | + @Autowired | |
| 72 | + ThreadMonotor threadMonotor; | |
| 73 | + | |
| 74 | + @Autowired | |
| 75 | + SeiPstThread seiPstThread; | |
| 76 | + | |
| 77 | + @Autowired | |
| 78 | + SampleTimeDataLoader sampleTimeDataLoader; | |
| 79 | + | |
| 80 | + @Autowired | |
| 81 | + SchSiginUpdateDBThread schSiginUpdateDBThread; | |
| 82 | + | |
| 83 | + @Autowired | |
| 84 | + AutoExecScanThread autoExecScanThread; | |
| 85 | + | |
| 86 | + @Autowired | |
| 87 | + GpsDataLoaderThread gpsDataLoader; | |
| 88 | + | |
| 89 | + @Autowired | |
| 90 | + OfflineMonitorThread offlineMonitorThread; | |
| 91 | + | |
| 92 | + @Autowired | |
| 93 | + LineVersionsData lineVersionsData; | |
| 94 | + | |
| 95 | + /*@Autowired | |
| 96 | + FixedEnableVerionsThread fixedEnableVerionsThread;*/ | |
| 97 | + | |
| 98 | + @Autowired | |
| 99 | + SafeDrivDataLoadThread safeDrivDataLoadThread; | |
| 100 | + | |
| 101 | + @Autowired | |
| 102 | + FixedCheckStationCodeThread fixedCheckStationCodeThread; | |
| 103 | + | |
| 104 | + private static long timeDiff; | |
| 105 | + private static long timeDiffTraffic; | |
| 106 | + | |
| 107 | + static { | |
| 108 | + // 早上2:20 | |
| 109 | + timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis(); | |
| 110 | + if (timeDiff < 0) | |
| 111 | + timeDiff += (1000 * 60 * 60 * 24); | |
| 112 | + // 早上07:00 | |
| 113 | + timeDiffTraffic = (DateUtils.getTimestamp() + 1000 * 60 * 60 * 7) - System.currentTimeMillis(); | |
| 114 | + if (timeDiffTraffic < 0) | |
| 115 | + timeDiffTraffic += (1000 * 60 * 60 * 24); | |
| 116 | + } | |
| 117 | + | |
| 118 | + @Override | |
| 119 | + public void run(String... strings) throws Exception { | |
| 120 | + try { | |
| 121 | + Tools tools = new Tools("application.properties"); | |
| 122 | + String environment = tools.getValue("spring.profiles.active"); | |
| 123 | + //预先加载基础的对照数据 | |
| 124 | + basicDataLoader.loadAllData(); | |
| 125 | + switch (environment){ | |
| 126 | + case "dev": | |
| 127 | + devInit(); | |
| 128 | + break; | |
| 129 | + case "prod": | |
| 130 | + prodInit(); | |
| 131 | + break; | |
| 132 | + } | |
| 133 | + }catch (Exception e){ | |
| 134 | + log.error("线调后台启动出现异常!!", e); | |
| 135 | + System.exit(1); | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 139 | + @Autowired | |
| 140 | + DayOfSchedule dayOfSchedule; | |
| 141 | + public void devInit(){ | |
| 142 | + log.info("devInit..."); | |
| 143 | + ScheduledExecutorService sexec = Application.mainServices; | |
| 144 | + //抓取GPS数据 | |
| 145 | + GpsDataLoaderThread.setFlag(-1); | |
| 146 | + //dayOfSchedule.dataRecovery(); | |
| 147 | + //sexec.scheduleWithFixedDelay(gpsDataLoader, 60, 4, TimeUnit.SECONDS); | |
| 148 | + //实际排班更新线程 | |
| 149 | + //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); | |
| 150 | + //sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 30, TimeUnit.SECONDS);//检查班次误点 | |
| 151 | + //sexec.scheduleWithFixedDelay(autoExecScanThread, 100, 50, TimeUnit.SECONDS);//班次自动执行 | |
| 152 | + //WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | |
| 153 | + | |
| 154 | + //sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 50, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码 | |
| 155 | + //实际排班延迟入库线程 | |
| 156 | + //sexec.scheduleWithFixedDelay(schedulePstThread, 60, 15, TimeUnit.SECONDS); | |
| 157 | + //班次修正日志延迟入库 | |
| 158 | + //sexec.scheduleWithFixedDelay(seiPstThread, 60, 30, TimeUnit.SECONDS); | |
| 159 | + //调度指令延迟入库 | |
| 160 | + //sexec.scheduleWithFixedDelay(directivesPstThread, 180, 180, TimeUnit.SECONDS); | |
| 161 | + //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | |
| 162 | + //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS); | |
| 163 | + | |
| 164 | + //安全驾驶 | |
| 165 | + //sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 40, 30, TimeUnit.SECONDS); | |
| 166 | + | |
| 167 | + //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 20, 60 * 2 , TimeUnit.SECONDS); | |
| 168 | + } | |
| 169 | + | |
| 170 | + public void prodInit(){ | |
| 171 | + log.info("prodInit..."); | |
| 172 | + ScheduledExecutorService sexec = Application.mainServices; | |
| 173 | + //安全驾驶 | |
| 174 | + //sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 175 | + | |
| 176 | + /** 线调业务 */ | |
| 177 | + sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 | |
| 178 | + sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 20, TimeUnit.SECONDS);//检查班次误点 | |
| 179 | + GpsDataLoaderThread.setFlag(-1); | |
| 180 | + sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据 | |
| 181 | + sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 60, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码 | |
| 182 | + | |
| 183 | + sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线 | |
| 184 | + sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程 | |
| 185 | + sexec.scheduleWithFixedDelay(seiPstThread, 180, 60, TimeUnit.SECONDS);//班次修正日志入库 | |
| 186 | + sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS);//调度指令延迟入库 | |
| 187 | + //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | |
| 188 | + sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据 | |
| 189 | + sexec.scheduleWithFixedDelay(basicDataLoader, 1, 1, TimeUnit.HOURS);//基础数据更新 | |
| 190 | + sexec.scheduleWithFixedDelay(whiteIpDataLoader, 0, 1, TimeUnit.MINUTES);//IP白名单数据更新 | |
| 191 | + sexec.scheduleWithFixedDelay(autoExecScanThread, 180, 50, TimeUnit.SECONDS);//班次自动执行 | |
| 192 | + DirectivePushQueue.start();//消息队列 -指令,系统下发的 | |
| 193 | + WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | |
| 194 | + | |
| 195 | + /** 线调为其他程序提供的数据 --写入数据库 */ | |
| 196 | + sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布) | |
| 197 | + //线路首末班数据(网关用,班次更新时写入) | |
| 198 | + //com.bsth.data.schedule.f_a_l.FirstAndLastHandler | |
| 199 | + sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) | |
| 200 | + | |
| 201 | + //运管处静态数据提交 | |
| 202 | + log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); | |
| 203 | + sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 204 | + //计算油、公里加注 | |
| 205 | + sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 206 | + | |
| 207 | + //线路版本更新 | |
| 208 | + sexec.scheduleWithFixedDelay(lineVersionsData, 60 * 5, 60 * 15, TimeUnit.SECONDS); | |
| 209 | + | |
| 210 | + //线路版本更新 | |
| 211 | + //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS); | |
| 212 | + } | |
| 213 | +} | ... | ... |
src/main/java/com/bsth/common/Setting.java
0 → 100644
| 1 | +package com.bsth.common; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Value; | |
| 4 | +import org.springframework.stereotype.Component; | |
| 5 | + | |
| 6 | +@Component | |
| 7 | +public class Setting { | |
| 8 | + | |
| 9 | + @Value("${enabled.whiteip}") | |
| 10 | + private boolean whiteipEnabled; | |
| 11 | + | |
| 12 | + public boolean isWhiteipEnabled() { | |
| 13 | + return whiteipEnabled; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public void setWhiteipEnabled(boolean whiteipEnabled) { | |
| 17 | + this.whiteipEnabled = whiteipEnabled; | |
| 18 | + } | |
| 19 | +} | |
| 0 | 20 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/BasicData.java
| ... | ... | @@ -12,6 +12,8 @@ import org.apache.commons.lang3.StringUtils; |
| 12 | 12 | import org.slf4j.Logger; |
| 13 | 13 | import org.slf4j.LoggerFactory; |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 16 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 15 | 17 | import org.springframework.stereotype.Component; |
| 16 | 18 | |
| 17 | 19 | import java.util.*; |
| ... | ... | @@ -77,6 +79,8 @@ public class BasicData { |
| 77 | 79 | //站点名和运管处编号 对照 |
| 78 | 80 | public static Map<String, Integer> stationName2YgcNumber; |
| 79 | 81 | |
| 82 | + public static List<WhiteIp> whiteIpList; | |
| 83 | + | |
| 80 | 84 | private static Map<String, SystemParam> key2param = new HashMap<>(); |
| 81 | 85 | |
| 82 | 86 | static Logger logger = LoggerFactory.getLogger(BasicData.class); |
| ... | ... | @@ -391,6 +395,41 @@ public class BasicData { |
| 391 | 395 | } |
| 392 | 396 | } |
| 393 | 397 | |
| 398 | + @Component | |
| 399 | + public static class WhiteIpDataLoader extends Thread { | |
| 400 | + @Autowired | |
| 401 | + JdbcTemplate jdbcTemplate; | |
| 402 | + | |
| 403 | + @Override | |
| 404 | + public void run() { | |
| 405 | + // IP白名单 | |
| 406 | + loadData(); | |
| 407 | + } | |
| 408 | + | |
| 409 | + /** | |
| 410 | + * @Title: loadAllData | |
| 411 | + * @Description: TODO(加载所有数据) | |
| 412 | + */ | |
| 413 | + public int loadData() { | |
| 414 | + try { | |
| 415 | + logger.info("开始加载IP白名单数据..,"); | |
| 416 | + loadWhiteIp(); | |
| 417 | + logger.info("加载IP白名单数据成功!,"); | |
| 418 | + } catch (Exception e) { | |
| 419 | + logger.error("加载IP白名单数据时出现异常,", e); | |
| 420 | + } | |
| 421 | + return 0; | |
| 422 | + } | |
| 423 | + | |
| 424 | + /** | |
| 425 | + * 加载IP白名单 | |
| 426 | + */ | |
| 427 | + public void loadWhiteIp() { | |
| 428 | + List<WhiteIp> result = jdbcTemplate.query("select * from control_interface.bsth_c_white_ip where valid_date > now()", BeanPropertyRowMapper.newInstance(WhiteIp.class)); | |
| 429 | + whiteIpList = result; | |
| 430 | + } | |
| 431 | + } | |
| 432 | + | |
| 394 | 433 | public static Map<String, SystemParam> getSystemParam() { |
| 395 | 434 | return key2param; |
| 396 | 435 | } | ... | ... |
src/main/java/com/bsth/entity/WhiteIp.java
0 → 100644
| 1 | +package com.bsth.entity; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
| 4 | + | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @author Hill | |
| 10 | + */ | |
| 11 | +public class WhiteIp { | |
| 12 | + | |
| 13 | + @JsonIgnore | |
| 14 | + private Integer id; | |
| 15 | + | |
| 16 | + private String ip; | |
| 17 | + | |
| 18 | + private String commitCompany; | |
| 19 | + | |
| 20 | + private String commitBcompany; | |
| 21 | + | |
| 22 | + @JsonIgnore | |
| 23 | + private String commitName; | |
| 24 | + | |
| 25 | + private Date validDate; | |
| 26 | + | |
| 27 | + @JsonIgnore | |
| 28 | + private String hash; | |
| 29 | + | |
| 30 | + @JsonIgnore | |
| 31 | + private Date createDate; | |
| 32 | + | |
| 33 | + @JsonIgnore | |
| 34 | + private Date updateDate; | |
| 35 | + | |
| 36 | + public Integer getId() { | |
| 37 | + return id; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setId(Integer id) { | |
| 41 | + this.id = id; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public String getIp() { | |
| 45 | + return ip; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setIp(String ip) { | |
| 49 | + this.ip = ip; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public String getCommitCompany() { | |
| 53 | + return commitCompany; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public void setCommitCompany(String commitCompany) { | |
| 57 | + this.commitCompany = commitCompany; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public String getCommitBcompany() { | |
| 61 | + return commitBcompany; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setCommitBcompany(String commitBcompany) { | |
| 65 | + this.commitBcompany = commitBcompany; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public String getCommitName() { | |
| 69 | + return commitName; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public void setCommitName(String commitName) { | |
| 73 | + this.commitName = commitName; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public Date getValidDate() { | |
| 77 | + return validDate; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void setValidDate(Date validDate) { | |
| 81 | + this.validDate = validDate; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public String getHash() { | |
| 85 | + return hash; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void setHash(String hash) { | |
| 89 | + this.hash = hash; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public Date getCreateDate() { | |
| 93 | + return createDate; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setCreateDate(Date createDate) { | |
| 97 | + this.createDate = createDate; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public Date getUpdateDate() { | |
| 101 | + return updateDate; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void setUpdateDate(Date updateDate) { | |
| 105 | + this.updateDate = updateDate; | |
| 106 | + } | |
| 107 | +} | |
| 0 | 108 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/filter/WhiteIpFilter.java
0 → 100644
| 1 | +package com.bsth.filter; | |
| 2 | + | |
| 3 | +import com.bsth.common.Setting; | |
| 4 | +import com.bsth.data.BasicData; | |
| 5 | +import com.bsth.entity.WhiteIp; | |
| 6 | +import com.bsth.util.IpUtils; | |
| 7 | +import org.slf4j.Logger; | |
| 8 | +import org.slf4j.LoggerFactory; | |
| 9 | +import org.springframework.stereotype.Component; | |
| 10 | + | |
| 11 | +import javax.servlet.*; | |
| 12 | +import javax.servlet.http.HttpServletRequest; | |
| 13 | +import javax.servlet.http.HttpServletResponse; | |
| 14 | +import java.io.IOException; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * IP白名单过滤器 | |
| 19 | + * @author Hill | |
| 20 | + */ | |
| 21 | +//@Component | |
| 22 | +public class WhiteIpFilter implements Filter { | |
| 23 | + | |
| 24 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 25 | + | |
| 26 | + private Setting setting; | |
| 27 | + | |
| 28 | + public Setting getSetting() { | |
| 29 | + return setting; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public void setSetting(Setting setting) { | |
| 33 | + this.setting = setting; | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public void init(FilterConfig filterConfig) throws ServletException { | |
| 38 | + | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | |
| 43 | + HttpServletRequest req = (HttpServletRequest)request; | |
| 44 | + HttpServletResponse res = (HttpServletResponse)response; | |
| 45 | + | |
| 46 | + String ip = IpUtils.getIpAddr(req); | |
| 47 | + boolean isMatch = false; | |
| 48 | + List<WhiteIp> whiteIps = BasicData.whiteIpList; | |
| 49 | + if (whiteIps != null) { | |
| 50 | + for (WhiteIp whiteIp : whiteIps) { | |
| 51 | + if (ip.equals(whiteIp.getIp())) { | |
| 52 | + isMatch = true; | |
| 53 | + break; | |
| 54 | + } | |
| 55 | + } | |
| 56 | + } | |
| 57 | + if (isMatch || !setting.isWhiteipEnabled()) { | |
| 58 | + chain.doFilter(request, response); | |
| 59 | + } else { | |
| 60 | + logger.info(ip + "未在白名单中,不予访问"); | |
| 61 | + res.setStatus(404); | |
| 62 | + return; | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public void destroy() { | |
| 68 | + | |
| 69 | + } | |
| 70 | +} | |
| 0 | 71 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/security/WebSecurityConfig.java
| 1 | -package com.bsth.security; | |
| 2 | - | |
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | -import org.springframework.boot.context.embedded.ServletListenerRegistrationBean; | |
| 5 | -import org.springframework.context.annotation.Bean; | |
| 6 | -import org.springframework.context.annotation.Configuration; | |
| 7 | -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
| 8 | -import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
| 9 | -import org.springframework.security.config.annotation.web.builders.WebSecurity; | |
| 10 | -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
| 11 | -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
| 12 | -import org.springframework.security.core.session.SessionRegistry; | |
| 13 | -import org.springframework.security.core.session.SessionRegistryImpl; | |
| 14 | -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
| 15 | -import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; | |
| 16 | -import org.springframework.security.web.session.HttpSessionEventPublisher; | |
| 17 | - | |
| 18 | -import com.bsth.common.Constants; | |
| 19 | -import com.bsth.security.filter.LoginInterceptor; | |
| 20 | - | |
| 21 | -@Configuration | |
| 22 | -@EnableWebSecurity | |
| 23 | -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |
| 24 | - | |
| 25 | - @Autowired | |
| 26 | - UserDetailServiceImpl customUserDetailService; | |
| 27 | - | |
| 28 | - @Autowired | |
| 29 | - CustomAccessDecisionManager customAccessDecisionManager; | |
| 30 | - | |
| 31 | - @Autowired | |
| 32 | - SecurityMetadataSourceService securityMetadataSourceService; | |
| 33 | - | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void configure(WebSecurity web) throws Exception { | |
| 37 | - // 白名单 | |
| 38 | - web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, | |
| 39 | - Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT); | |
| 40 | - } | |
| 41 | - | |
| 42 | - @Override | |
| 43 | - protected void configure(AuthenticationManagerBuilder auth) | |
| 44 | - throws Exception { | |
| 45 | - auth.userDetailsService(customUserDetailService).passwordEncoder( | |
| 46 | - new BCryptPasswordEncoder(4)); | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - protected void configure(HttpSecurity http) throws Exception { | |
| 51 | - http.authorizeRequests().antMatchers("/").permitAll().anyRequest() | |
| 52 | - .authenticated().and() | |
| 53 | - .formLogin() | |
| 54 | - //指定登录页 | |
| 55 | - .loginPage(Constants.LOGIN_PAGE) | |
| 56 | - .loginProcessingUrl(Constants.LOGIN).permitAll() | |
| 57 | - .and().logout() | |
| 58 | - //禁用CXRF | |
| 59 | - .and().csrf().disable() | |
| 60 | - //禁用匿名用户功能 | |
| 61 | - .anonymous().disable() | |
| 62 | - //允许 iframe | |
| 63 | - .headers().frameOptions().disable(); | |
| 64 | - | |
| 65 | - // 同时只保持一个回话 | |
| 66 | - http.sessionManagement().maximumSessions(1) | |
| 67 | - .expiredUrl(Constants.LOGIN_PAGE + "?error=true") | |
| 68 | - .maxSessionsPreventsLogin(false)//让之前的登录过期 | |
| 69 | - .sessionRegistry(sessionRegistry()); | |
| 70 | - | |
| 71 | - http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class); | |
| 72 | - http.addFilter(filterSecurityInterceptor()); | |
| 73 | - } | |
| 74 | - | |
| 75 | - private FilterSecurityInterceptor filterSecurityInterceptor() | |
| 76 | - throws Exception { | |
| 77 | - FilterSecurityInterceptor filterSecurityInterceptor = new FilterSecurityInterceptor(); | |
| 78 | - filterSecurityInterceptor | |
| 79 | - .setAccessDecisionManager(customAccessDecisionManager); | |
| 80 | - filterSecurityInterceptor | |
| 81 | - .setSecurityMetadataSource(securityMetadataSourceService); | |
| 82 | - filterSecurityInterceptor | |
| 83 | - .setAuthenticationManager(authenticationManager()); | |
| 84 | - return filterSecurityInterceptor; | |
| 85 | - } | |
| 86 | - | |
| 87 | -/* @Bean | |
| 88 | - public LoginSuccessHandler loginSuccessHandler(){ | |
| 89 | - return new LoginSuccessHandler(); | |
| 90 | - }*/ | |
| 91 | - | |
| 92 | -/* @Bean | |
| 93 | - public LogoutHandler logoutHandler(){ | |
| 94 | - return new CustomLogoutHandler(); | |
| 95 | - }*/ | |
| 96 | - | |
| 97 | - @Bean | |
| 98 | - public SessionRegistry sessionRegistry() { | |
| 99 | - SessionRegistry sessionRegistry = new SessionRegistryImpl(); | |
| 100 | - return sessionRegistry; | |
| 101 | - } | |
| 102 | - | |
| 103 | - @Bean | |
| 104 | - public static ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { | |
| 105 | - return new ServletListenerRegistrationBean<HttpSessionEventPublisher>( | |
| 106 | - new HttpSessionEventPublisher()); | |
| 107 | - } | |
| 108 | -} | |
| 1 | +package com.bsth.security; | |
| 2 | + | |
| 3 | +import com.bsth.common.Setting; | |
| 4 | +import com.bsth.filter.WhiteIpFilter; | |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | +import org.springframework.beans.factory.annotation.Value; | |
| 7 | +import org.springframework.boot.context.embedded.ServletListenerRegistrationBean; | |
| 8 | +import org.springframework.context.annotation.Bean; | |
| 9 | +import org.springframework.context.annotation.Configuration; | |
| 10 | +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
| 11 | +import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
| 12 | +import org.springframework.security.config.annotation.web.builders.WebSecurity; | |
| 13 | +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
| 14 | +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
| 15 | +import org.springframework.security.core.session.SessionRegistry; | |
| 16 | +import org.springframework.security.core.session.SessionRegistryImpl; | |
| 17 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
| 18 | +import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; | |
| 19 | +import org.springframework.security.web.firewall.DefaultHttpFirewall; | |
| 20 | +import org.springframework.security.web.firewall.HttpFirewall; | |
| 21 | +import org.springframework.security.web.session.HttpSessionEventPublisher; | |
| 22 | + | |
| 23 | +import com.bsth.common.Constants; | |
| 24 | +import com.bsth.security.filter.LoginInterceptor; | |
| 25 | + | |
| 26 | +@Configuration | |
| 27 | +@EnableWebSecurity | |
| 28 | +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + UserDetailServiceImpl customUserDetailService; | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + CustomAccessDecisionManager customAccessDecisionManager; | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + SecurityMetadataSourceService securityMetadataSourceService; | |
| 38 | + | |
| 39 | + @Autowired | |
| 40 | + private Setting setting; | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public void configure(WebSecurity web) throws Exception { | |
| 44 | + // 白名单 | |
| 45 | + web.ignoring().antMatchers(Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, | |
| 46 | + Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, | |
| 47 | + Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + protected void configure(AuthenticationManagerBuilder auth) | |
| 52 | + throws Exception { | |
| 53 | + auth.userDetailsService(customUserDetailService).passwordEncoder( | |
| 54 | + new BCryptPasswordEncoder(4)); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + protected void configure(HttpSecurity http) throws Exception { | |
| 59 | + http.authorizeRequests().antMatchers("/").permitAll().anyRequest() | |
| 60 | + .authenticated().and() | |
| 61 | + .formLogin() | |
| 62 | + //指定登录页 | |
| 63 | + .loginPage(Constants.LOGIN_PAGE) | |
| 64 | + .loginProcessingUrl(Constants.LOGIN).permitAll() | |
| 65 | + .and().logout().logoutSuccessUrl(Constants.LOGIN_PAGE) | |
| 66 | + //禁用CXRF | |
| 67 | + .and().csrf().disable() | |
| 68 | + //禁用匿名用户功能 | |
| 69 | + .anonymous().disable() | |
| 70 | + //允许 iframe | |
| 71 | + .headers().frameOptions().disable(); | |
| 72 | + | |
| 73 | + // 同时只保持一个回话 maxSessionsPreventsLogin(false)让之前的登录过期 | |
| 74 | + http.sessionManagement().maximumSessions(1) | |
| 75 | + .expiredUrl(Constants.LOGIN_PAGE + "?error=true") | |
| 76 | + .maxSessionsPreventsLogin(false) | |
| 77 | + .sessionRegistry(sessionRegistry()); | |
| 78 | + | |
| 79 | + WhiteIpFilter whiteIpFilter = new WhiteIpFilter(); | |
| 80 | + whiteIpFilter.setSetting(setting); | |
| 81 | + http.addFilterBefore(whiteIpFilter, FilterSecurityInterceptor.class); | |
| 82 | + http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class); | |
| 83 | + http.addFilter(filterSecurityInterceptor()); | |
| 84 | + } | |
| 85 | + | |
| 86 | + private FilterSecurityInterceptor filterSecurityInterceptor() | |
| 87 | + throws Exception { | |
| 88 | + FilterSecurityInterceptor filterSecurityInterceptor = new FilterSecurityInterceptor(); | |
| 89 | + filterSecurityInterceptor | |
| 90 | + .setAccessDecisionManager(customAccessDecisionManager); | |
| 91 | + filterSecurityInterceptor | |
| 92 | + .setSecurityMetadataSource(securityMetadataSourceService); | |
| 93 | + filterSecurityInterceptor | |
| 94 | + .setAuthenticationManager(authenticationManager()); | |
| 95 | + return filterSecurityInterceptor; | |
| 96 | + } | |
| 97 | + | |
| 98 | + @Bean | |
| 99 | + public SessionRegistry sessionRegistry() { | |
| 100 | + SessionRegistry sessionRegistry = new SessionRegistryImpl(); | |
| 101 | + return sessionRegistry; | |
| 102 | + } | |
| 103 | + | |
| 104 | + @Bean | |
| 105 | + public static ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { | |
| 106 | + return new ServletListenerRegistrationBean<HttpSessionEventPublisher>( | |
| 107 | + new HttpSessionEventPublisher()); | |
| 108 | + } | |
| 109 | + | |
| 110 | + @Bean | |
| 111 | + public HttpFirewall httpFirewall() { | |
| 112 | + return new DefaultHttpFirewall(); | |
| 113 | + } | |
| 114 | +} | ... | ... |
src/main/resources/application-prod.properties
| 1 | -server.port=9088 | |
| 2 | -management.port= 9001 | |
| 3 | -management.address= 127.0.0.1 | |
| 4 | - | |
| 5 | -dubbo.use=true | |
| 6 | - | |
| 7 | -spring.jpa.hibernate.ddl-auto= none | |
| 8 | -spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | |
| 9 | -#DATABASE | |
| 10 | -spring.jpa.database= MYSQL | |
| 11 | -spring.jpa.show-sql= true | |
| 12 | -spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 13 | -spring.datasource.url= jdbc:mysql://192.168.40.100:3306/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 14 | -spring.datasource.username= root | |
| 15 | -spring.datasource.password= root@JSP2jsp | |
| 16 | -#DATASOURCE | |
| 17 | -spring.datasource.max-active=100 | |
| 18 | -spring.datasource.max-idle=8 | |
| 19 | -spring.datasource.min-idle=8 | |
| 20 | -spring.datasource.initial-size=5 | |
| 21 | - | |
| 22 | -spring.datasource.test-on-borrow=true | |
| 23 | -spring.datasource.test-on-connect=true | |
| 24 | -spring.datasource.test-on-return=true | |
| 25 | -spring.datasource.test-while-idle=true | |
| 26 | -spring.datasource.validation-query=select 1 | |
| 27 | - | |
| 28 | -## gateway real data | |
| 29 | -http.gps.real.url= http://192.168.40.82:8080/transport_server/rtgps/ | |
| 30 | -## gateway send directive | |
| 31 | -http.send.directive = http://192.168.40.82:8080/transport_server/message/ | |
| 1 | +server.port=9088 | |
| 2 | +management.port= 9001 | |
| 3 | +management.address= 127.0.0.1 | |
| 4 | + | |
| 5 | +dubbo.use= false | |
| 6 | + | |
| 7 | +spring.jpa.hibernate.ddl-auto= none | |
| 8 | +spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | |
| 9 | +#DATABASE | |
| 10 | +spring.jpa.database= MYSQL | |
| 11 | +spring.jpa.show-sql= true | |
| 12 | +spring.datasource.driver-class-name= com.mysql.jdbc.Driver | |
| 13 | +spring.datasource.url= jdbc:mysql://192.168.40.100:3306/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 14 | +spring.datasource.username= root | |
| 15 | +spring.datasource.password= root@JSP2jsp | |
| 16 | +#DATASOURCE | |
| 17 | +spring.datasource.max-active=100 | |
| 18 | +spring.datasource.max-idle=8 | |
| 19 | +spring.datasource.min-idle=8 | |
| 20 | +spring.datasource.initial-size=5 | |
| 21 | + | |
| 22 | +spring.datasource.test-on-borrow=true | |
| 23 | +spring.datasource.test-on-connect=true | |
| 24 | +spring.datasource.test-on-return=true | |
| 25 | +spring.datasource.test-while-idle=true | |
| 26 | +spring.datasource.validation-query=select 1 | |
| 27 | + | |
| 28 | +## gateway real data | |
| 29 | +http.gps.real.url= http://192.168.40.82:8080/transport_server/rtgps/ | |
| 30 | +## gateway send directive | |
| 31 | +http.send.directive = http://192.168.40.82:8080/transport_server/message/ | ... | ... |