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 | 20 | public static final String METRONIC_URL = "/metronic_v4.5.4/**"; |
| 21 | 21 | public static final String LOGIN_FAILURE = "/user/loginFailure"; |
| 22 | 22 | public static final String CAPTCHA = "/captcha.jpg"; |
| 23 | - | |
| 23 | + | |
| 24 | 24 | /** |
| 25 | 25 | * 线调部分子页面不做拦截,便于浏览器缓存 |
| 26 | 26 | */ |
| ... | ... | @@ -29,7 +29,7 @@ public class Constants { |
| 29 | 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 | 34 | public static final String SESSION_USERNAME = "sessionUserName"; |
| 35 | 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 | 238 | |
| 239 | 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 | 242 | List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql); |
| 243 | 243 | Map<String, Double> speedTempMap = new HashMap<>(); |
| 244 | 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 | 247 | speedLimitMap = speedTempMap; |
| 248 | 248 | } | ... | ... |
src/main/java/com/bsth/filter/BaseFilter.java
| 1 | 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 | 4 | import org.springframework.util.AntPathMatcher; |
| 15 | 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 | 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 | 22 | @EnableWebSecurity |
| 23 | 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 | 88 | /* @Bean |
| 89 | 89 | public LoginSuccessHandler loginSuccessHandler(){ |
| 90 | 90 | return new LoginSuccessHandler(); |
| ... | ... | @@ -95,15 +95,15 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| 95 | 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 | 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 | 11 | import javax.servlet.FilterChain; |
| 9 | -import javax.servlet.FilterConfig; | |
| 10 | 12 | import javax.servlet.ServletException; |
| 11 | 13 | import javax.servlet.ServletRequest; |
| 12 | 14 | import javax.servlet.ServletResponse; |
| 13 | 15 | import javax.servlet.http.HttpServletRequest; |
| 14 | 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 | 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 | 31 | @Override |
| 37 | 32 | public void destroy() { |
| ... | ... | @@ -63,22 +58,4 @@ public class LoginInterceptor extends AbstractSecurityInterceptor implements Fil |
| 63 | 58 | |
| 64 | 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 | 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 | 6 | import org.slf4j.Logger; |
| 6 | 7 | import org.slf4j.LoggerFactory; |
| 7 | 8 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| 9 | +import org.springframework.security.core.GrantedAuthority; | |
| 10 | +import org.springframework.security.core.authority.SimpleGrantedAuthority; | |
| 8 | 11 | import org.springframework.security.core.context.SecurityContext; |
| 9 | 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 | 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 | 357 | var pjaxContainer = '#pjax-container' |
| 358 | 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 | 367 | $(function () { |
| 361 | 368 | $.get('/user/currentUser', function (user) { |
| 362 | 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 | 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 | 232 | svg.line-chart .merge_hide { |
| 222 | 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 | 25 | }); |
| 26 | 26 | |
| 27 | 27 | return rs; |
| 28 | - } | |
| 28 | + }; | |
| 29 | 29 | |
| 30 | 30 | var compileTempByDom = function (dom, opts) { |
| 31 | 31 | var tps = {}, |
| ... | ... | @@ -36,7 +36,7 @@ var gb_common = (function () { |
| 36 | 36 | tps[id] = template.compile($(this).html(), opts); |
| 37 | 37 | }); |
| 38 | 38 | return tps; |
| 39 | - } | |
| 39 | + }; | |
| 40 | 40 | |
| 41 | 41 | var $get = function (url, data, successFun) { |
| 42 | 42 | $.ajax({ |
| ... | ... | @@ -46,7 +46,7 @@ var gb_common = (function () { |
| 46 | 46 | ajaxComplete(xhr, ts, successFun); |
| 47 | 47 | } |
| 48 | 48 | }); |
| 49 | - } | |
| 49 | + }; | |
| 50 | 50 | |
| 51 | 51 | var $post = function (url, data, successFun) { |
| 52 | 52 | $.ajax({ |
| ... | ... | @@ -57,7 +57,7 @@ var gb_common = (function () { |
| 57 | 57 | ajaxComplete(xhr, ts, successFun); |
| 58 | 58 | } |
| 59 | 59 | }); |
| 60 | - } | |
| 60 | + }; | |
| 61 | 61 | |
| 62 | 62 | var $post_arr = function (url, data, successFun) { |
| 63 | 63 | $.ajax({ |
| ... | ... | @@ -69,20 +69,20 @@ var gb_common = (function () { |
| 69 | 69 | ajaxComplete(xhr, ts, successFun); |
| 70 | 70 | } |
| 71 | 71 | }); |
| 72 | - } | |
| 72 | + }; | |
| 73 | 73 | |
| 74 | 74 | var $del = function (url, successFun) { |
| 75 | 75 | $post(url, {'_method': 'delete'}, function (rs) { |
| 76 | 76 | successFun && successFun(rs); |
| 77 | 77 | }); |
| 78 | - } | |
| 78 | + }; | |
| 79 | 79 | |
| 80 | 80 | var errorHead = '<span style="color:red;">服务器出现异常:</span>'; |
| 81 | 81 | |
| 82 | 82 | function successHandle(json, handle) { |
| 83 | 83 | var status = json.status; |
| 84 | 84 | if (status == 407) { |
| 85 | - alert('被注销的登录'); | |
| 85 | + //alert('被注销的登录'); | |
| 86 | 86 | location.href = '/'; |
| 87 | 87 | return; |
| 88 | 88 | } |
| ... | ... | @@ -113,7 +113,7 @@ var gb_common = (function () { |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | return array; |
| 116 | - } | |
| 116 | + }; | |
| 117 | 117 | |
| 118 | 118 | var get_keys = function (json) { |
| 119 | 119 | var array = []; |
| ... | ... | @@ -121,7 +121,7 @@ var gb_common = (function () { |
| 121 | 121 | array.push(key); |
| 122 | 122 | } |
| 123 | 123 | return array; |
| 124 | - } | |
| 124 | + }; | |
| 125 | 125 | |
| 126 | 126 | var get_device_tree_data = function (allGps, idBefore) { |
| 127 | 127 | if (!idBefore) | ... | ... |
src/main/resources/static/real_control_v2/js/utils/dispatch_pattern.js
| ... | ... | @@ -12,12 +12,18 @@ else |
| 12 | 12 | //拦截POST请求 |
| 13 | 13 | function interceptPOST(e, xhr, t) { |
| 14 | 14 | if (t && (t.method == 'POST' || t.type == 'POST')) { |
| 15 | - console.log(e, xhr, t); | |
| 16 | 15 | xhr.abort(); |
| 17 | 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 | 28 | //10分钟后提交当班调度数据 |
| 23 | 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 | 220 | if (d.nbbm.indexOf('-') > 0) { |
| 221 | 221 | t = d.nbbm.substr(d.nbbm.indexOf('-') - 1, 1) + t; |
| 222 | 222 | } |
| 223 | - return t; | |
| 223 | + return t + d.suffix; | |
| 224 | 224 | }, |
| 225 | 225 | gps_key = function (d) { |
| 226 | 226 | return d.deviceId; |
| ... | ... | @@ -234,13 +234,16 @@ var gb_svg_chart = (function () { |
| 234 | 234 | else |
| 235 | 235 | $(this).show();//找不到停靠点,直接隐藏 |
| 236 | 236 | return x; |
| 237 | - }) | |
| 237 | + }) | |
| 238 | 238 | .attr('y', function (d) { |
| 239 | 239 | return gy(d, svg); |
| 240 | 240 | }) |
| 241 | 241 | .attr('updown', function (d) { |
| 242 | 242 | return d.upDown; |
| 243 | 243 | }); |
| 244 | + e.classed({'abnormal': function (d) { | |
| 245 | + return d.abnormalClaszz; | |
| 246 | + }}); | |
| 244 | 247 | //update tip position |
| 245 | 248 | gb_svg_tooltip.update(e); |
| 246 | 249 | }, |
| ... | ... | @@ -255,11 +258,24 @@ var gb_svg_chart = (function () { |
| 255 | 258 | var svgs = $('.line-chart[data-code=' + lineCode + ']'), |
| 256 | 259 | data = gb_data_gps.gpsByLineCode(lineCode); |
| 257 | 260 | |
| 258 | - var list = []; | |
| 261 | + var list = [], suffix; | |
| 259 | 262 | //过滤无站点字段的数据 |
| 260 | 263 | $.each(data, function () { |
| 261 | 264 | if (!this.stopNo || this.stopNo == '') |
| 262 | 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 | 279 | list.push(this); |
| 264 | 280 | }); |
| 265 | 281 | |
| ... | ... | @@ -283,7 +299,8 @@ var gb_svg_chart = (function () { |
| 283 | 299 | gps_update_point(rects, svg); |
| 284 | 300 | //text |
| 285 | 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 | 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 | 53 | else |
| 54 | 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 | 64 | |
| 65 | 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 | 69 | ctx.shadowBlur = 1; // 模糊尺寸 |
| 70 | 70 | ctx.shadowColor = colours.shadow; // 颜色 |
| 71 | 71 | |
| ... | ... | @@ -73,13 +73,13 @@ var gb_map_imap = (function () { |
| 73 | 73 | if (!w) |
| 74 | 74 | w = 70; |
| 75 | 75 | |
| 76 | - ctx.roundRect(0, 0, w, 25, 5).stroke(); | |
| 76 | + ctx.roundRect(0, 0, w, 19, 4).stroke(); | |
| 77 | 77 | ctx.fillStyle = colours.bgColor; |
| 78 | 78 | ctx.fill(); |
| 79 | 79 | //文字 |
| 80 | 80 | ctx.font = "14px arial"; |
| 81 | 81 | ctx.fillStyle = "#fff"; |
| 82 | - ctx.fillText(gps.nbbm, 4, 18); | |
| 82 | + ctx.fillText(gps.nbbm, 2, 14); | |
| 83 | 83 | |
| 84 | 84 | return canvas.toDataURL(); |
| 85 | 85 | } |
| ... | ... | @@ -107,7 +107,7 @@ var gb_map_imap = (function () { |
| 107 | 107 | //文字 |
| 108 | 108 | ctx.font = "14px arial"; |
| 109 | 109 | ctx.fillStyle = "#fff"; |
| 110 | - ctx.fillText(gps.nbbm, 4, 17); | |
| 110 | + ctx.fillText(gps.nbbm, 2, 17); | |
| 111 | 111 | |
| 112 | 112 | //角度图标 |
| 113 | 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 | 90 | var gpsArray = opts.gpsList; |
| 91 | 91 | var marker, coord; |
| 92 | 92 | $.each(gpsArray, function(i, gps){ |
| 93 | + if(!gps) | |
| 94 | + return true; | |
| 93 | 95 | |
| 94 | 96 | marker = realMarkers[gps.deviceId]; |
| 95 | 97 | if(marker && gps.timestamp == marker.gpsData.timestamp) |
| ... | ... | @@ -346,7 +348,7 @@ var gb_map_baidu = (function(){ |
| 346 | 348 | //根据站点名称 计算marker 宽度 |
| 347 | 349 | var w = statio.stationName.length * 12 + 4 |
| 348 | 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 | 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 | 238 | gpsArray = opts.gpsList; |
| 239 | 239 | var coord; |
| 240 | 240 | $.each(gpsArray, function(i, gps){ |
| 241 | + if(!gps) | |
| 242 | + return true; | |
| 241 | 243 | |
| 242 | 244 | marker = realMarkers[gps.deviceId]; |
| 243 | 245 | if(marker && gps.timestamp == marker.gpsData.timestamp) |
| ... | ... | @@ -352,10 +354,10 @@ var gb_map_gaode = (function() { |
| 352 | 354 | map: map, |
| 353 | 355 | position: [statio.gcj_lon, statio.gcj_lat], |
| 354 | 356 | icon: new AMap.Icon({ |
| 355 | - size: new AMap.Size(w, 24), //图标大小 | |
| 357 | + size: new AMap.Size(w, 20), //图标大小 | |
| 356 | 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