Commit 7d8e6d58aa98eada936630a0204e3bc4e270a3ce
1 parent
a17c901b
update
Showing
15 changed files
with
204 additions
and
181 deletions
src/main/java/com/bsth/common/Constants.java
| @@ -20,7 +20,7 @@ public class Constants { | @@ -20,7 +20,7 @@ public class Constants { | ||
| 20 | public static final String METRONIC_URL = "/metronic_v4.5.4/**"; | 20 | public static final String METRONIC_URL = "/metronic_v4.5.4/**"; |
| 21 | public static final String LOGIN_FAILURE = "/user/loginFailure"; | 21 | public static final String LOGIN_FAILURE = "/user/loginFailure"; |
| 22 | public static final String CAPTCHA = "/captcha.jpg"; | 22 | public static final String CAPTCHA = "/captcha.jpg"; |
| 23 | - | 23 | + |
| 24 | /** | 24 | /** |
| 25 | * 线调部分子页面不做拦截,便于浏览器缓存 | 25 | * 线调部分子页面不做拦截,便于浏览器缓存 |
| 26 | */ | 26 | */ |
| @@ -29,7 +29,7 @@ public class Constants { | @@ -29,7 +29,7 @@ public class Constants { | ||
| 29 | //public static final String XD_TEMPS = "/pages/control/line/temps/**"; | 29 | //public static final String XD_TEMPS = "/pages/control/line/temps/**"; |
| 30 | 30 | ||
| 31 | //车载网关上行接口 | 31 | //车载网关上行接口 |
| 32 | - public static final String UPSTREAM_URL = "/control/upstream"; | 32 | + public static final String UPSTREAM_URL = "/control/upstream/"; |
| 33 | 33 | ||
| 34 | public static final String SESSION_USERNAME = "sessionUserName"; | 34 | public static final String SESSION_USERNAME = "sessionUserName"; |
| 35 | public static final String COMPANY_AUTHORITYS = "cmyAuths"; | 35 | public static final String COMPANY_AUTHORITYS = "cmyAuths"; |
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
| @@ -238,11 +238,11 @@ public class GeoCacheData { | @@ -238,11 +238,11 @@ public class GeoCacheData { | ||
| 238 | 238 | ||
| 239 | private void loadSpeedLimit(){ | 239 | private void loadSpeedLimit(){ |
| 240 | //加载线路限速信息 | 240 | //加载线路限速信息 |
| 241 | - String sql = "select l.LINE_CODE,i.SPEED_LIMIT from bsth_c_line_information i left join bsth_c_line l on i.line=l.id where i.speed_limit is not null"; | 241 | + String sql = "select l.LINE_CODE,i.SPEEDING from bsth_c_line_information i left join bsth_c_line l on i.line=l.id where i.speed_limit is not null"; |
| 242 | List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql); | 242 | List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql); |
| 243 | Map<String, Double> speedTempMap = new HashMap<>(); | 243 | Map<String, Double> speedTempMap = new HashMap<>(); |
| 244 | for (Map<String, Object> tMap : speedMap) { | 244 | for (Map<String, Object> tMap : speedMap) { |
| 245 | - speedTempMap.put(tMap.get("LINE_CODE").toString(), Double.parseDouble(tMap.get("SPEED_LIMIT").toString())); | 245 | + speedTempMap.put(tMap.get("LINE_CODE").toString(), Double.parseDouble(tMap.get("SPEEDING").toString())); |
| 246 | } | 246 | } |
| 247 | speedLimitMap = speedTempMap; | 247 | speedLimitMap = speedTempMap; |
| 248 | } | 248 | } |
src/main/java/com/bsth/filter/BaseFilter.java
| 1 | package com.bsth.filter; | 1 | package com.bsth.filter; |
| 2 | 2 | ||
| 3 | -import java.io.IOException; | ||
| 4 | - | ||
| 5 | -import javax.servlet.Filter; | ||
| 6 | -import javax.servlet.FilterChain; | ||
| 7 | -import javax.servlet.FilterConfig; | ||
| 8 | -import javax.servlet.ServletException; | ||
| 9 | -import javax.servlet.ServletRequest; | ||
| 10 | -import javax.servlet.ServletResponse; | ||
| 11 | -import javax.servlet.http.HttpServletRequest; | ||
| 12 | -import javax.servlet.http.HttpServletResponse; | ||
| 13 | - | 3 | +import com.bsth.common.Constants; |
| 14 | import org.springframework.util.AntPathMatcher; | 4 | import org.springframework.util.AntPathMatcher; |
| 15 | import org.springframework.util.PathMatcher; | 5 | import org.springframework.util.PathMatcher; |
| 16 | 6 | ||
| 17 | -import com.bsth.common.Constants; | 7 | +import javax.servlet.*; |
| 8 | +import javax.servlet.http.HttpServletRequest; | ||
| 9 | +import javax.servlet.http.HttpServletResponse; | ||
| 10 | +import java.io.IOException; | ||
| 18 | 11 | ||
| 19 | public abstract class BaseFilter implements Filter { | 12 | public abstract class BaseFilter implements Filter { |
| 20 | 13 |
src/main/java/com/bsth/security/WebSecurityConfig.java
| @@ -22,69 +22,69 @@ import com.bsth.security.filter.LoginInterceptor; | @@ -22,69 +22,69 @@ import com.bsth.security.filter.LoginInterceptor; | ||
| 22 | @EnableWebSecurity | 22 | @EnableWebSecurity |
| 23 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | 23 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| 24 | 24 | ||
| 25 | - @Autowired | ||
| 26 | - UserDetailServiceImpl customUserDetailService; | 25 | + @Autowired |
| 26 | + UserDetailServiceImpl customUserDetailService; | ||
| 27 | 27 | ||
| 28 | - @Autowired | ||
| 29 | - CustomAccessDecisionManager customAccessDecisionManager; | 28 | + @Autowired |
| 29 | + CustomAccessDecisionManager customAccessDecisionManager; | ||
| 30 | 30 | ||
| 31 | - @Autowired | ||
| 32 | - SecurityMetadataSourceService securityMetadataSourceService; | 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.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS); | ||
| 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 | + //.failureUrl(Constants.LOGIN_PAGE + "?error=true")登录失败跳转的链接 | ||
| 58 | + //.successHandler(loginSuccessHandler())登录成功后处理 | ||
| 59 | + .and().logout() | ||
| 60 | + //.addLogoutHandler(logoutHandler()) | ||
| 61 | + //禁用CXRF | ||
| 62 | + .and().csrf().disable() | ||
| 63 | + //禁用匿名用户功能 | ||
| 64 | + .anonymous().disable(); | ||
| 65 | + | ||
| 66 | + // 同时只保持一个回话 | ||
| 67 | + http.sessionManagement().maximumSessions(1) | ||
| 68 | + .expiredUrl(Constants.LOGIN_PAGE + "?error=true") | ||
| 69 | + .maxSessionsPreventsLogin(false)//让之前的登录过期 | ||
| 70 | + .sessionRegistry(sessionRegistry()); | ||
| 71 | + | ||
| 72 | + http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class); | ||
| 73 | + http.addFilter(filterSecurityInterceptor()); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + private FilterSecurityInterceptor filterSecurityInterceptor() | ||
| 77 | + throws Exception { | ||
| 78 | + FilterSecurityInterceptor filterSecurityInterceptor = new FilterSecurityInterceptor(); | ||
| 79 | + filterSecurityInterceptor | ||
| 80 | + .setAccessDecisionManager(customAccessDecisionManager); | ||
| 81 | + filterSecurityInterceptor | ||
| 82 | + .setSecurityMetadataSource(securityMetadataSourceService); | ||
| 83 | + filterSecurityInterceptor | ||
| 84 | + .setAuthenticationManager(authenticationManager()); | ||
| 85 | + return filterSecurityInterceptor; | ||
| 86 | + } | ||
| 33 | 87 | ||
| 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.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES); | ||
| 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 | - //.failureUrl(Constants.LOGIN_PAGE + "?error=true")登录失败跳转的链接 | ||
| 58 | - //.successHandler(loginSuccessHandler())登录成功后处理 | ||
| 59 | - .and().logout() | ||
| 60 | - //.addLogoutHandler(logoutHandler()) | ||
| 61 | - //禁用CXRF | ||
| 62 | - .and().csrf().disable() | ||
| 63 | - //禁用匿名用户功能 | ||
| 64 | - .anonymous().disable(); | ||
| 65 | - | ||
| 66 | - // 同时只保持一个回话 | ||
| 67 | - http.sessionManagement().maximumSessions(1) | ||
| 68 | - .expiredUrl(Constants.LOGIN_PAGE + "?error=true") | ||
| 69 | - .maxSessionsPreventsLogin(false)//让之前的登录过期 | ||
| 70 | - .sessionRegistry(sessionRegistry()); | ||
| 71 | - | ||
| 72 | - http.addFilterBefore(new LoginInterceptor(), FilterSecurityInterceptor.class); | ||
| 73 | - http.addFilter(filterSecurityInterceptor()); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - private FilterSecurityInterceptor filterSecurityInterceptor() | ||
| 77 | - throws Exception { | ||
| 78 | - FilterSecurityInterceptor filterSecurityInterceptor = new FilterSecurityInterceptor(); | ||
| 79 | - filterSecurityInterceptor | ||
| 80 | - .setAccessDecisionManager(customAccessDecisionManager); | ||
| 81 | - filterSecurityInterceptor | ||
| 82 | - .setSecurityMetadataSource(securityMetadataSourceService); | ||
| 83 | - filterSecurityInterceptor | ||
| 84 | - .setAuthenticationManager(authenticationManager()); | ||
| 85 | - return filterSecurityInterceptor; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | /* @Bean | 88 | /* @Bean |
| 89 | public LoginSuccessHandler loginSuccessHandler(){ | 89 | public LoginSuccessHandler loginSuccessHandler(){ |
| 90 | return new LoginSuccessHandler(); | 90 | return new LoginSuccessHandler(); |
| @@ -95,15 +95,15 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -95,15 +95,15 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 95 | return new CustomLogoutHandler(); | 95 | return new CustomLogoutHandler(); |
| 96 | }*/ | 96 | }*/ |
| 97 | 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 | - } | 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 | } | 109 | } |
src/main/java/com/bsth/security/filter/LoginInterceptor.java
| 1 | package com.bsth.security.filter; | 1 | package com.bsth.security.filter; |
| 2 | 2 | ||
| 3 | -import java.io.IOException; | ||
| 4 | -import java.util.HashMap; | ||
| 5 | -import java.util.Map; | 3 | +import com.alibaba.fastjson.JSON; |
| 4 | +import com.bsth.common.Constants; | ||
| 5 | +import com.bsth.common.ResponseCode; | ||
| 6 | +import com.bsth.filter.BaseFilter; | ||
| 7 | +import com.bsth.util.RequestUtils; | ||
| 8 | +import org.springframework.security.core.Authentication; | ||
| 9 | +import org.springframework.security.core.context.SecurityContextHolder; | ||
| 6 | 10 | ||
| 7 | -import javax.servlet.Filter; | ||
| 8 | import javax.servlet.FilterChain; | 11 | import javax.servlet.FilterChain; |
| 9 | -import javax.servlet.FilterConfig; | ||
| 10 | import javax.servlet.ServletException; | 12 | import javax.servlet.ServletException; |
| 11 | import javax.servlet.ServletRequest; | 13 | import javax.servlet.ServletRequest; |
| 12 | import javax.servlet.ServletResponse; | 14 | import javax.servlet.ServletResponse; |
| 13 | import javax.servlet.http.HttpServletRequest; | 15 | import javax.servlet.http.HttpServletRequest; |
| 14 | import javax.servlet.http.HttpServletResponse; | 16 | import javax.servlet.http.HttpServletResponse; |
| 15 | - | ||
| 16 | -import org.springframework.security.access.SecurityMetadataSource; | ||
| 17 | -import org.springframework.security.access.intercept.AbstractSecurityInterceptor; | ||
| 18 | -import org.springframework.security.core.Authentication; | ||
| 19 | -import org.springframework.security.core.context.SecurityContextHolder; | ||
| 20 | - | ||
| 21 | -import com.alibaba.fastjson.JSON; | ||
| 22 | -import com.bsth.common.Constants; | ||
| 23 | -import com.bsth.common.ResponseCode; | ||
| 24 | -import com.bsth.util.RequestUtils; | 17 | +import java.io.IOException; |
| 18 | +import java.util.HashMap; | ||
| 19 | +import java.util.Map; | ||
| 25 | 20 | ||
| 26 | /** | 21 | /** |
| 27 | * | 22 | * |
| @@ -31,7 +26,7 @@ import com.bsth.util.RequestUtils; | @@ -31,7 +26,7 @@ import com.bsth.util.RequestUtils; | ||
| 31 | * @date 2016年3月24日 上午11:49:20 | 26 | * @date 2016年3月24日 上午11:49:20 |
| 32 | * | 27 | * |
| 33 | */ | 28 | */ |
| 34 | -public class LoginInterceptor extends AbstractSecurityInterceptor implements Filter{ | 29 | +public class LoginInterceptor extends BaseFilter{ |
| 35 | 30 | ||
| 36 | @Override | 31 | @Override |
| 37 | public void destroy() { | 32 | public void destroy() { |
| @@ -63,22 +58,4 @@ public class LoginInterceptor extends AbstractSecurityInterceptor implements Fil | @@ -63,22 +58,4 @@ public class LoginInterceptor extends AbstractSecurityInterceptor implements Fil | ||
| 63 | 58 | ||
| 64 | arg2.doFilter(arg0, arg1); | 59 | arg2.doFilter(arg0, arg1); |
| 65 | } | 60 | } |
| 66 | - | ||
| 67 | - @Override | ||
| 68 | - public void init(FilterConfig arg0) throws ServletException { | ||
| 69 | - | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @Override | ||
| 73 | - public Class<?> getSecureObjectClass() { | ||
| 74 | - // TODO Auto-generated method stub | ||
| 75 | - return null; | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - @Override | ||
| 79 | - public SecurityMetadataSource obtainSecurityMetadataSource() { | ||
| 80 | - // TODO Auto-generated method stub | ||
| 81 | - return null; | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | } | 61 | } |
src/main/java/com/bsth/security/util/SecurityUtils.java
| 1 | package com.bsth.security.util; | 1 | package com.bsth.security.util; |
| 2 | 2 | ||
| 3 | -import javax.servlet.http.HttpServletRequest; | ||
| 4 | - | 3 | +import com.bsth.entity.sys.Role; |
| 4 | +import com.bsth.entity.sys.SecurityUser; | ||
| 5 | +import com.bsth.entity.sys.SysUser; | ||
| 5 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 6 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 7 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | 8 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| 9 | +import org.springframework.security.core.GrantedAuthority; | ||
| 10 | +import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
| 8 | import org.springframework.security.core.context.SecurityContext; | 11 | import org.springframework.security.core.context.SecurityContext; |
| 9 | import org.springframework.security.core.context.SecurityContextHolder; | 12 | import org.springframework.security.core.context.SecurityContextHolder; |
| 10 | 13 | ||
| 11 | -import com.bsth.entity.sys.SecurityUser; | ||
| 12 | -import com.bsth.entity.sys.SysUser; | 14 | +import javax.servlet.http.HttpServletRequest; |
| 15 | +import java.util.ArrayList; | ||
| 16 | +import java.util.List; | ||
| 17 | +import java.util.Set; | ||
| 13 | 18 | ||
| 14 | /** | 19 | /** |
| 15 | - * | ||
| 16 | - * @ClassName: SecurityUtils | ||
| 17 | - * @author PanZhao | ||
| 18 | - * @date 2016年3月30日 上午11:28:24 | ||
| 19 | - * | 20 | + * @author PanZhao |
| 21 | + * @ClassName: SecurityUtils | ||
| 22 | + * @date 2016年3月30日 上午11:28:24 | ||
| 20 | */ | 23 | */ |
| 21 | public class SecurityUtils { | 24 | public class SecurityUtils { |
| 22 | - | ||
| 23 | - static Logger logger = LoggerFactory.getLogger(SecurityUtils.class); | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * | ||
| 27 | - * @Title: getCurrentUser | ||
| 28 | - * @Description: TODO(获取当前用户) | ||
| 29 | - * @return SysUser 返回类型 | ||
| 30 | - * @throws | ||
| 31 | - */ | ||
| 32 | - public static SysUser getCurrentUser(){ | ||
| 33 | - SysUser user = null; | ||
| 34 | - try{ | ||
| 35 | - user = (SysUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | ||
| 36 | - }catch(Exception e){ | ||
| 37 | - logger.error("", e); | ||
| 38 | - } | ||
| 39 | - return user; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - public static void login(SysUser user, HttpServletRequest request){ | ||
| 43 | - SecurityUser securityUser = new SecurityUser(user); | ||
| 44 | - SecurityContext sContext = SecurityContextHolder.getContext(); | ||
| 45 | - sContext.setAuthentication( | ||
| 46 | - new UsernamePasswordAuthenticationToken(securityUser, securityUser.getAuthorities())); | ||
| 47 | - request.getSession(true).setAttribute("SPRING_SECURITY_CONTEXT", sContext); | ||
| 48 | - } | 25 | + |
| 26 | + static Logger logger = LoggerFactory.getLogger(SecurityUtils.class); | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @return SysUser 返回类型 | ||
| 30 | + * @throws | ||
| 31 | + * @Title: getCurrentUser | ||
| 32 | + * @Description: TODO(获取当前用户) | ||
| 33 | + */ | ||
| 34 | + public static SysUser getCurrentUser() { | ||
| 35 | + SysUser user = null; | ||
| 36 | + try { | ||
| 37 | + user = (SysUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | ||
| 38 | + } catch (Exception e) { | ||
| 39 | + logger.error("", e); | ||
| 40 | + } | ||
| 41 | + return user; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public static void login(SysUser user, HttpServletRequest request) { | ||
| 45 | + SecurityUser securityUser = new SecurityUser(user); | ||
| 46 | + SecurityContext sContext = SecurityContextHolder.getContext(); | ||
| 47 | + | ||
| 48 | + List<GrantedAuthority> grantedAuths = new ArrayList<>(); | ||
| 49 | + Set<Role> set = user.getRoles(); | ||
| 50 | + for(Role r : set){ | ||
| 51 | + grantedAuths.add(new SimpleGrantedAuthority(r.getCodeName())); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + sContext.setAuthentication(new UsernamePasswordAuthenticationToken(securityUser, securityUser.getAuthorities(), grantedAuths)); | ||
| 55 | + request.getSession(true).setAttribute("SPRING_SECURITY_CONTEXT", sContext); | ||
| 56 | + } | ||
| 49 | } | 57 | } |
src/main/resources/static/index.html
| @@ -357,6 +357,13 @@ | @@ -357,6 +357,13 @@ | ||
| 357 | var pjaxContainer = '#pjax-container' | 357 | var pjaxContainer = '#pjax-container' |
| 358 | , angJsContainer = '#route-container'; | 358 | , angJsContainer = '#route-container'; |
| 359 | 359 | ||
| 360 | + $(document).ajaxError(function (event, jqxhr, settings, thrownError) { | ||
| 361 | + if(jqxhr.status == 403){ | ||
| 362 | + layer.closeAll(); | ||
| 363 | + layer.alert(jqxhr.message?jqxhr.message:'访问被拒绝', {icon: 2, title: '操作失败'}); | ||
| 364 | + } | ||
| 365 | + }); | ||
| 366 | + | ||
| 360 | $(function () { | 367 | $(function () { |
| 361 | $.get('/user/currentUser', function (user) { | 368 | $.get('/user/currentUser', function (user) { |
| 362 | $('#indexTopUName').text(user.userName); | 369 | $('#indexTopUName').text(user.userName); |
src/main/resources/static/real_control_v2/css/main.css
| @@ -218,6 +218,17 @@ svg.line-chart g.gps-wrap>text[updown="1"] { | @@ -218,6 +218,17 @@ svg.line-chart g.gps-wrap>text[updown="1"] { | ||
| 218 | fill: #fff; | 218 | fill: #fff; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | +svg.line-chart g.gps-wrap>rect.abnormal[updown="0"] , | ||
| 222 | +svg.line-chart g.gps-wrap>rect.abnormal[updown="1"]{ | ||
| 223 | + width: 40px; | ||
| 224 | + fill: yellow; | ||
| 225 | + stroke: yellow; | ||
| 226 | +} | ||
| 227 | +svg.line-chart g.gps-wrap>text.abnormal[updown="0"], | ||
| 228 | +svg.line-chart g.gps-wrap>text.abnormal[updown="1"]{ | ||
| 229 | + fill: black; | ||
| 230 | +} | ||
| 231 | + | ||
| 221 | svg.line-chart .merge_hide { | 232 | svg.line-chart .merge_hide { |
| 222 | display: none !important; | 233 | display: none !important; |
| 223 | } | 234 | } |
src/main/resources/static/real_control_v2/js/common.js
| @@ -25,7 +25,7 @@ var gb_common = (function () { | @@ -25,7 +25,7 @@ var gb_common = (function () { | ||
| 25 | }); | 25 | }); |
| 26 | 26 | ||
| 27 | return rs; | 27 | return rs; |
| 28 | - } | 28 | + }; |
| 29 | 29 | ||
| 30 | var compileTempByDom = function (dom, opts) { | 30 | var compileTempByDom = function (dom, opts) { |
| 31 | var tps = {}, | 31 | var tps = {}, |
| @@ -36,7 +36,7 @@ var gb_common = (function () { | @@ -36,7 +36,7 @@ var gb_common = (function () { | ||
| 36 | tps[id] = template.compile($(this).html(), opts); | 36 | tps[id] = template.compile($(this).html(), opts); |
| 37 | }); | 37 | }); |
| 38 | return tps; | 38 | return tps; |
| 39 | - } | 39 | + }; |
| 40 | 40 | ||
| 41 | var $get = function (url, data, successFun) { | 41 | var $get = function (url, data, successFun) { |
| 42 | $.ajax({ | 42 | $.ajax({ |
| @@ -46,7 +46,7 @@ var gb_common = (function () { | @@ -46,7 +46,7 @@ var gb_common = (function () { | ||
| 46 | ajaxComplete(xhr, ts, successFun); | 46 | ajaxComplete(xhr, ts, successFun); |
| 47 | } | 47 | } |
| 48 | }); | 48 | }); |
| 49 | - } | 49 | + }; |
| 50 | 50 | ||
| 51 | var $post = function (url, data, successFun) { | 51 | var $post = function (url, data, successFun) { |
| 52 | $.ajax({ | 52 | $.ajax({ |
| @@ -57,7 +57,7 @@ var gb_common = (function () { | @@ -57,7 +57,7 @@ var gb_common = (function () { | ||
| 57 | ajaxComplete(xhr, ts, successFun); | 57 | ajaxComplete(xhr, ts, successFun); |
| 58 | } | 58 | } |
| 59 | }); | 59 | }); |
| 60 | - } | 60 | + }; |
| 61 | 61 | ||
| 62 | var $post_arr = function (url, data, successFun) { | 62 | var $post_arr = function (url, data, successFun) { |
| 63 | $.ajax({ | 63 | $.ajax({ |
| @@ -69,20 +69,20 @@ var gb_common = (function () { | @@ -69,20 +69,20 @@ var gb_common = (function () { | ||
| 69 | ajaxComplete(xhr, ts, successFun); | 69 | ajaxComplete(xhr, ts, successFun); |
| 70 | } | 70 | } |
| 71 | }); | 71 | }); |
| 72 | - } | 72 | + }; |
| 73 | 73 | ||
| 74 | var $del = function (url, successFun) { | 74 | var $del = function (url, successFun) { |
| 75 | $post(url, {'_method': 'delete'}, function (rs) { | 75 | $post(url, {'_method': 'delete'}, function (rs) { |
| 76 | successFun && successFun(rs); | 76 | successFun && successFun(rs); |
| 77 | }); | 77 | }); |
| 78 | - } | 78 | + }; |
| 79 | 79 | ||
| 80 | var errorHead = '<span style="color:red;">服务器出现异常:</span>'; | 80 | var errorHead = '<span style="color:red;">服务器出现异常:</span>'; |
| 81 | 81 | ||
| 82 | function successHandle(json, handle) { | 82 | function successHandle(json, handle) { |
| 83 | var status = json.status; | 83 | var status = json.status; |
| 84 | if (status == 407) { | 84 | if (status == 407) { |
| 85 | - alert('被注销的登录'); | 85 | + //alert('被注销的登录'); |
| 86 | location.href = '/'; | 86 | location.href = '/'; |
| 87 | return; | 87 | return; |
| 88 | } | 88 | } |
| @@ -113,7 +113,7 @@ var gb_common = (function () { | @@ -113,7 +113,7 @@ var gb_common = (function () { | ||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | return array; | 115 | return array; |
| 116 | - } | 116 | + }; |
| 117 | 117 | ||
| 118 | var get_keys = function (json) { | 118 | var get_keys = function (json) { |
| 119 | var array = []; | 119 | var array = []; |
| @@ -121,7 +121,7 @@ var gb_common = (function () { | @@ -121,7 +121,7 @@ var gb_common = (function () { | ||
| 121 | array.push(key); | 121 | array.push(key); |
| 122 | } | 122 | } |
| 123 | return array; | 123 | return array; |
| 124 | - } | 124 | + }; |
| 125 | 125 | ||
| 126 | var get_device_tree_data = function (allGps, idBefore) { | 126 | var get_device_tree_data = function (allGps, idBefore) { |
| 127 | if (!idBefore) | 127 | if (!idBefore) |
src/main/resources/static/real_control_v2/js/utils/dispatch_pattern.js
| @@ -12,12 +12,18 @@ else | @@ -12,12 +12,18 @@ else | ||
| 12 | //拦截POST请求 | 12 | //拦截POST请求 |
| 13 | function interceptPOST(e, xhr, t) { | 13 | function interceptPOST(e, xhr, t) { |
| 14 | if (t && (t.method == 'POST' || t.type == 'POST')) { | 14 | if (t && (t.method == 'POST' || t.type == 'POST')) { |
| 15 | - console.log(e, xhr, t); | ||
| 16 | xhr.abort(); | 15 | xhr.abort(); |
| 17 | notify_err('监控模式!'); | 16 | notify_err('监控模式!'); |
| 18 | } | 17 | } |
| 19 | } | 18 | } |
| 20 | 19 | ||
| 20 | +//全局 ajaxError 事件 | ||
| 21 | +$(document).ajaxError(function (event, jqxhr) { | ||
| 22 | + if(jqxhr.status == 403){ | ||
| 23 | + UIkit.modal.alert('<span style="color: red;">访问被拒绝,你没有这个权限!</span>', {labels: {Ok: '确定'}}); | ||
| 24 | + } | ||
| 25 | +}); | ||
| 26 | + | ||
| 21 | 27 | ||
| 22 | //10分钟后提交当班调度数据 | 28 | //10分钟后提交当班调度数据 |
| 23 | setTimeout(function () { | 29 | setTimeout(function () { |
src/main/resources/static/real_control_v2/js/utils/svg_chart.js
| @@ -220,7 +220,7 @@ var gb_svg_chart = (function () { | @@ -220,7 +220,7 @@ var gb_svg_chart = (function () { | ||
| 220 | if (d.nbbm.indexOf('-') > 0) { | 220 | if (d.nbbm.indexOf('-') > 0) { |
| 221 | t = d.nbbm.substr(d.nbbm.indexOf('-') - 1, 1) + t; | 221 | t = d.nbbm.substr(d.nbbm.indexOf('-') - 1, 1) + t; |
| 222 | } | 222 | } |
| 223 | - return t; | 223 | + return t + d.suffix; |
| 224 | }, | 224 | }, |
| 225 | gps_key = function (d) { | 225 | gps_key = function (d) { |
| 226 | return d.deviceId; | 226 | return d.deviceId; |
| @@ -234,13 +234,16 @@ var gb_svg_chart = (function () { | @@ -234,13 +234,16 @@ var gb_svg_chart = (function () { | ||
| 234 | else | 234 | else |
| 235 | $(this).show();//找不到停靠点,直接隐藏 | 235 | $(this).show();//找不到停靠点,直接隐藏 |
| 236 | return x; | 236 | return x; |
| 237 | - }) | 237 | + }) |
| 238 | .attr('y', function (d) { | 238 | .attr('y', function (d) { |
| 239 | return gy(d, svg); | 239 | return gy(d, svg); |
| 240 | }) | 240 | }) |
| 241 | .attr('updown', function (d) { | 241 | .attr('updown', function (d) { |
| 242 | return d.upDown; | 242 | return d.upDown; |
| 243 | }); | 243 | }); |
| 244 | + e.classed({'abnormal': function (d) { | ||
| 245 | + return d.abnormalClaszz; | ||
| 246 | + }}); | ||
| 244 | //update tip position | 247 | //update tip position |
| 245 | gb_svg_tooltip.update(e); | 248 | gb_svg_tooltip.update(e); |
| 246 | }, | 249 | }, |
| @@ -255,11 +258,24 @@ var gb_svg_chart = (function () { | @@ -255,11 +258,24 @@ var gb_svg_chart = (function () { | ||
| 255 | var svgs = $('.line-chart[data-code=' + lineCode + ']'), | 258 | var svgs = $('.line-chart[data-code=' + lineCode + ']'), |
| 256 | data = gb_data_gps.gpsByLineCode(lineCode); | 259 | data = gb_data_gps.gpsByLineCode(lineCode); |
| 257 | 260 | ||
| 258 | - var list = []; | 261 | + var list = [], suffix; |
| 259 | //过滤无站点字段的数据 | 262 | //过滤无站点字段的数据 |
| 260 | $.each(data, function () { | 263 | $.each(data, function () { |
| 261 | if (!this.stopNo || this.stopNo == '') | 264 | if (!this.stopNo || this.stopNo == '') |
| 262 | return true; | 265 | return true; |
| 266 | + | ||
| 267 | + suffix = ''; | ||
| 268 | + this['abnormalClaszz'] = true; | ||
| 269 | + if(this['abnormalStatus']=='outBounds'){ | ||
| 270 | + suffix = '界'; | ||
| 271 | + } | ||
| 272 | + else if(this['abnormalStatus']=='overspeed'){ | ||
| 273 | + suffix = '速'; | ||
| 274 | + } | ||
| 275 | + else | ||
| 276 | + this['abnormalClaszz'] = false; | ||
| 277 | + | ||
| 278 | + this.suffix = suffix; | ||
| 263 | list.push(this); | 279 | list.push(this); |
| 264 | }); | 280 | }); |
| 265 | 281 | ||
| @@ -283,7 +299,8 @@ var gb_svg_chart = (function () { | @@ -283,7 +299,8 @@ var gb_svg_chart = (function () { | ||
| 283 | gps_update_point(rects, svg); | 299 | gps_update_point(rects, svg); |
| 284 | //text | 300 | //text |
| 285 | var ts = gps_cont.selectAll('text').data(data, gps_key); | 301 | var ts = gps_cont.selectAll('text').data(data, gps_key); |
| 286 | - ts.enter().append('text').text(g_text).attr('_id', tx_id); | 302 | + ts.enter().append('text').attr('_id', tx_id); |
| 303 | + ts.text(g_text) | ||
| 287 | gps_update_point(ts, svg); | 304 | gps_update_point(ts, svg); |
| 288 | }; | 305 | }; |
| 289 | 306 |
src/main/resources/static/real_control_v2/mapmonitor/js/map/iMap.js
| @@ -53,7 +53,7 @@ var gb_map_imap = (function () { | @@ -53,7 +53,7 @@ var gb_map_imap = (function () { | ||
| 53 | else | 53 | else |
| 54 | width += 16; | 54 | width += 16; |
| 55 | });*/ | 55 | });*/ |
| 56 | - return nbbm.length * 9.8; | 56 | + return nbbm.length * 8.85; |
| 57 | } | 57 | } |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| @@ -64,8 +64,8 @@ var gb_map_imap = (function () { | @@ -64,8 +64,8 @@ var gb_map_imap = (function () { | ||
| 64 | 64 | ||
| 65 | var colours = color(gps); | 65 | var colours = color(gps); |
| 66 | 66 | ||
| 67 | - ctx.shadowOffsetX = 5; // 阴影Y轴偏移 | ||
| 68 | - ctx.shadowOffsetY = 5; // 阴影X轴偏移 | 67 | + ctx.shadowOffsetX = 3; // 阴影Y轴偏移 |
| 68 | + ctx.shadowOffsetY = 3; // 阴影X轴偏移 | ||
| 69 | ctx.shadowBlur = 1; // 模糊尺寸 | 69 | ctx.shadowBlur = 1; // 模糊尺寸 |
| 70 | ctx.shadowColor = colours.shadow; // 颜色 | 70 | ctx.shadowColor = colours.shadow; // 颜色 |
| 71 | 71 | ||
| @@ -73,13 +73,13 @@ var gb_map_imap = (function () { | @@ -73,13 +73,13 @@ var gb_map_imap = (function () { | ||
| 73 | if (!w) | 73 | if (!w) |
| 74 | w = 70; | 74 | w = 70; |
| 75 | 75 | ||
| 76 | - ctx.roundRect(0, 0, w, 25, 5).stroke(); | 76 | + ctx.roundRect(0, 0, w, 19, 4).stroke(); |
| 77 | ctx.fillStyle = colours.bgColor; | 77 | ctx.fillStyle = colours.bgColor; |
| 78 | ctx.fill(); | 78 | ctx.fill(); |
| 79 | //文字 | 79 | //文字 |
| 80 | ctx.font = "14px arial"; | 80 | ctx.font = "14px arial"; |
| 81 | ctx.fillStyle = "#fff"; | 81 | ctx.fillStyle = "#fff"; |
| 82 | - ctx.fillText(gps.nbbm, 4, 18); | 82 | + ctx.fillText(gps.nbbm, 2, 14); |
| 83 | 83 | ||
| 84 | return canvas.toDataURL(); | 84 | return canvas.toDataURL(); |
| 85 | } | 85 | } |
| @@ -107,7 +107,7 @@ var gb_map_imap = (function () { | @@ -107,7 +107,7 @@ var gb_map_imap = (function () { | ||
| 107 | //文字 | 107 | //文字 |
| 108 | ctx.font = "14px arial"; | 108 | ctx.font = "14px arial"; |
| 109 | ctx.fillStyle = "#fff"; | 109 | ctx.fillStyle = "#fff"; |
| 110 | - ctx.fillText(gps.nbbm, 4, 17); | 110 | + ctx.fillText(gps.nbbm, 2, 17); |
| 111 | 111 | ||
| 112 | //角度图标 | 112 | //角度图标 |
| 113 | var img = new Image(); | 113 | var img = new Image(); |
src/main/resources/static/real_control_v2/mapmonitor/js/map/platform/baidu.js
| @@ -90,6 +90,8 @@ var gb_map_baidu = (function(){ | @@ -90,6 +90,8 @@ var gb_map_baidu = (function(){ | ||
| 90 | var gpsArray = opts.gpsList; | 90 | var gpsArray = opts.gpsList; |
| 91 | var marker, coord; | 91 | var marker, coord; |
| 92 | $.each(gpsArray, function(i, gps){ | 92 | $.each(gpsArray, function(i, gps){ |
| 93 | + if(!gps) | ||
| 94 | + return true; | ||
| 93 | 95 | ||
| 94 | marker = realMarkers[gps.deviceId]; | 96 | marker = realMarkers[gps.deviceId]; |
| 95 | if(marker && gps.timestamp == marker.gpsData.timestamp) | 97 | if(marker && gps.timestamp == marker.gpsData.timestamp) |
| @@ -346,7 +348,7 @@ var gb_map_baidu = (function(){ | @@ -346,7 +348,7 @@ var gb_map_baidu = (function(){ | ||
| 346 | //根据站点名称 计算marker 宽度 | 348 | //根据站点名称 计算marker 宽度 |
| 347 | var w = statio.stationName.length * 12 + 4 | 349 | var w = statio.stationName.length * 12 + 4 |
| 348 | ,iw=w-2; | 350 | ,iw=w-2; |
| 349 | - var icon = new BMap.Icon(gb_map_imap.createStationIcon(statio, w), new BMap.Size(iw,24), {anchor: new BMap.Size(iw/2,24)}) | 351 | + var icon = new BMap.Icon(gb_map_imap.createStationIcon(statio, w), new BMap.Size(iw,20), {anchor: new BMap.Size(iw/2,20)}) |
| 350 | marker.setIcon(icon); | 352 | marker.setIcon(icon); |
| 351 | 353 | ||
| 352 | //信息窗口 | 354 | //信息窗口 |
src/main/resources/static/real_control_v2/mapmonitor/js/map/platform/gaode.js
| @@ -238,6 +238,8 @@ var gb_map_gaode = (function() { | @@ -238,6 +238,8 @@ var gb_map_gaode = (function() { | ||
| 238 | gpsArray = opts.gpsList; | 238 | gpsArray = opts.gpsList; |
| 239 | var coord; | 239 | var coord; |
| 240 | $.each(gpsArray, function(i, gps){ | 240 | $.each(gpsArray, function(i, gps){ |
| 241 | + if(!gps) | ||
| 242 | + return true; | ||
| 241 | 243 | ||
| 242 | marker = realMarkers[gps.deviceId]; | 244 | marker = realMarkers[gps.deviceId]; |
| 243 | if(marker && gps.timestamp == marker.gpsData.timestamp) | 245 | if(marker && gps.timestamp == marker.gpsData.timestamp) |
| @@ -352,10 +354,10 @@ var gb_map_gaode = (function() { | @@ -352,10 +354,10 @@ var gb_map_gaode = (function() { | ||
| 352 | map: map, | 354 | map: map, |
| 353 | position: [statio.gcj_lon, statio.gcj_lat], | 355 | position: [statio.gcj_lon, statio.gcj_lat], |
| 354 | icon: new AMap.Icon({ | 356 | icon: new AMap.Icon({ |
| 355 | - size: new AMap.Size(w, 24), //图标大小 | 357 | + size: new AMap.Size(w, 20), //图标大小 |
| 356 | image: gb_map_imap.createStationIcon(statio, w) | 358 | image: gb_map_imap.createStationIcon(statio, w) |
| 357 | }), | 359 | }), |
| 358 | - offset: new AMap.Pixel(-(w/2), -24) | 360 | + offset: new AMap.Pixel(-(w/2), -20) |
| 359 | }); | 361 | }); |
| 360 | 362 | ||
| 361 | //信息窗口 | 363 | //信息窗口 |
src/main/resources/static/real_control_v2/mapmonitor/real.html
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | <form class="uk-form" data-uk-margin=""> | 29 | <form class="uk-form" data-uk-margin=""> |
| 30 | <div class="uk-form-icon"> | 30 | <div class="uk-form-icon"> |
| 31 | <i class="uk-icon-search"></i> | 31 | <i class="uk-icon-search"></i> |
| 32 | - <input type="text" placeholder="搜索..." > | 32 | + <input type="text" placeholder="搜索..." disabled> |
| 33 | </div> | 33 | </div> |
| 34 | </form> | 34 | </form> |
| 35 | 35 |