Commit 86d276b713334abe45cccb39132b238de5b33f7b

Authored by 潘钊
1 parent 239bb73e

update...

src/main/java/com/bsth/controller/sys/UserController.java
... ... @@ -31,220 +31,252 @@ import java.util.*;
31 31 @RequestMapping("user")
32 32 public class UserController extends BaseController<SysUser, Integer> {
33 33  
34   - Logger logger = LoggerFactory.getLogger(this.getClass());
35   -
36   - @Autowired
37   - SysUserService sysUserService;
38   -
39   - @Autowired
40   - CompanyAuthorityService companyAuthorityService;
41   -
42   - @RequestMapping(value = "/login/jCryptionKey")
43   - public Map<String, Object> jCryptionKey(HttpServletRequest request){
44   - //公匙返回页面
45   - Map<String, Object> rs = new HashMap<>();
46   - rs.put("publickey", RSAUtils.generateBase64PublicKey());
47   - return rs;
48   - }
49   -
50   - //需要验证码的账号
51   - public static Map<String, Integer> captchaMap = new HashMap<>();
52   -
53   - @RequestMapping(value = "/login", method = RequestMethod.POST)
54   - public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
55   - @RequestParam String password, String captcha) {
56   -
57   - Map<String, Object> rs = new HashMap<>();
58   - rs.put("status", ResponseCode.ERROR);
59   - try {
60   - HttpSession session = request.getSession();
61   - rs.put("captcha", session.getAttribute("captcha"));
62   -
63   - if(captchaMap.get(userName) != null && captchaMap.get(userName) >= 3){
64   - //校验验证码
65   - String verCode = (String) session
66   - .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
67   -
68   - if(StringUtils.isBlank(captcha))
69   - return put(rs, "msg", "请输入验证码");
70   -
71   - if(!verCode.equals(captcha))
72   - return put(rs, "msg", "验证码有误,请刷新后重新输入");
73   - }
74   -
75   - //解密RSA
76   - try {
77   - userName = RSAUtils.decryptBase64(userName);
78   - password = RSAUtils.decryptBase64(password);
79   - } catch (RuntimeException e) {
80   - return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。");
81   - }
82   -
83   - SysUser user = sysUserService.findByUserName(userName);
84   - if (null == user)
85   - return put(rs, "msg", "不存在的用户");
86   -
87   - if (!user.isEnabled())
88   - return put(rs, "msg", "该用户已被锁定,请联系管理员");
89   -
90   - // 校验密码
91   - boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
92   - if (!matchStatus) {
93   - rs.put("msg", "密码有误");
94   -
95   - Integer captchSize = captchaMap.get(userName);
96   - if(null == captchSize)
97   - captchSize = 0;
98   -
99   - captchSize ++;
100   - captchaMap.put(userName, captchSize);
101   - return rs;
102   - }
103   -
104   - // 登录
105   - SecurityUtils.login(user, request);
106   - //session里写入用户名,webSocket连接时标识身份用
107   - session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
108   -
109   - //获取公司权限数据
110   - List<CompanyAuthority> cmyAuths=companyAuthorityService.findByUser(user);
111   - session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
112   -
113   - captchaMap.remove(userName);
114   - rs.put("status", ResponseCode.SUCCESS);
115   - } catch (Exception e) {
116   - logger.error("", e);
117   - rs.put("msg", "服务器出现异常,请联系管理员");
118   - }
119   - return rs;
120   - }
121   -
122   - /**
123   - * 返回当前用户的公司权限数据,用于构建页面级联下拉框
124   - * @return
125   - */
126   - @RequestMapping("companyData")
127   - public List<CompanyData> companyData(HttpServletRequest request){
128   - List<CompanyData> rs = new ArrayList<>();
129   - CompanyData companyData;
130   -
131   - ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create();
132   - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
133   -
134   - for(CompanyAuthority cAuth : cmyAuths){
135   - map.put(cAuth.getCompanyCode()+"_"+cAuth.getCompanyName(), cAuth);
136   - }
137   -
138   - Set<String> keys = map.keySet();
139   - String[] temps;
140   - for(String k : keys){
141   - temps = k.split("_");
142   -
143   - companyData = new CompanyData();
144   - companyData.setCompanyCode(temps[0]);
145   - companyData.setCompanyName(temps[1]);
146   - companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>());
147   -
148   - cmyAuths = map.get(k);
149   - for(CompanyAuthority c : cmyAuths){
150   - companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName()));
151   - }
152   -
153   - rs.add(companyData);
154   - }
155   -
156   - return rs;
157   - }
158   -
159   - @RequestMapping(value = "/login/captchaStatus")
160   - public int captchaStatus(String userName){
161   - Integer size = captchaMap.get(userName);
162   - return size == null?0:size;
163   - }
164   -
165   - public Map<String, Object> put(Map<String, Object> rs, String key, Object val){
166   - rs.put(key, val);
167   - return rs;
168   - }
169   -
170   - /**
171   - *
172   - * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param
173   - * request @return String 返回类型 @throws
174   - */
175   - @RequestMapping("/loginFailure")
176   - public String loginFailure(HttpServletRequest request) {
177   - String msg = "";
178   - HttpSession session = request.getSession();
179   -
180   - Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
181   -
182   - if (obj instanceof BadCredentialsException)
183   - msg = "登录失败,用户名或密码错误.";
184   - else if (obj instanceof SessionAuthenticationException)
185   - msg = "登录失败,当前策略不允许重复登录.";
186   - session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
187   - return msg;
188   - }
189   -
190   - @RequestMapping("/currentUser")
191   - public SysUser currentUser() {
192   - return SecurityUtils.getCurrentUser();
193   - }
194   -
195   - /**
196   - * @Title changeEnabled
197   - * @Description: TODO(改变用户状态)
198   - * @param id
199   - * 用户ID
200   - * @param enabled
201   - * 状态
202   - * @return
203   - */
204   - @RequestMapping("/changeEnabled")
205   - public int changeEnabled(@RequestParam int id, @RequestParam int enabled) {
206   - return sysUserService.changeEnabled(id, enabled);
207   - }
208   -
209   - /**
210   - * @Title changePWD
211   - * @Description: TODO(修改密码)
212   - * @param oldPWD
213   - * 原始密码
214   - * @param newPWD
215   - * 新密码
216   - * @param cnewPWD
217   - * 确认新密码
218   - * @return
219   - */
220   - @RequestMapping(value = "/changePWD", method = RequestMethod.POST)
221   - public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) {
222   - SysUser sysUser = SecurityUtils.getCurrentUser();
223   - String msg = "";
224   - if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) {
225   - if (oldPWD.equals(newPWD)) {
226   - msg = "新密码不能跟原始密码一样!";
227   - } else {
228   - if (newPWD.equals(cnewPWD)) {
229   - sysUserService.changePWD(sysUser.getId(), newPWD);
230   - msg = "修改成功!";
231   - } else {
232   - msg = "新密码两次输入不一致!";
233   - }
234   - }
235   - } else {
236   - msg = "原始密码错误!";
237   - }
238   - return msg;
239   - }
240   -
241   - @RequestMapping(value = "/register" ,method = RequestMethod.POST)
242   - public Map<String, Object> register(SysUser u){
243   - return sysUserService.register(u);
244   - }
245   -
246   - @RequestMapping(value = "/all_distinct")
247   - public List<SysUser> findAll_distinct(){
248   - return sysUserService.findAll_distinct();
249   - }
  34 + Logger logger = LoggerFactory.getLogger(this.getClass());
  35 +
  36 + @Autowired
  37 + SysUserService sysUserService;
  38 +
  39 + @Autowired
  40 + CompanyAuthorityService companyAuthorityService;
  41 +
  42 + @RequestMapping(value = "/login/jCryptionKey")
  43 + public Map<String, Object> jCryptionKey(HttpServletRequest request) {
  44 + //公匙返回页面
  45 + Map<String, Object> rs = new HashMap<>();
  46 + rs.put("publickey", RSAUtils.generateBase64PublicKey());
  47 + return rs;
  48 + }
  49 +
  50 + //需要验证码的账号
  51 + public static Map<String, Integer> captchaMap = new HashMap<>();
  52 +
  53 + @RequestMapping(value = "/login", method = RequestMethod.POST)
  54 + public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
  55 + @RequestParam String password, String captcha) {
  56 +
  57 + Map<String, Object> rs = new HashMap<>();
  58 + rs.put("status", ResponseCode.ERROR);
  59 + try {
  60 + HttpSession session = request.getSession();
  61 + rs.put("captcha", session.getAttribute("captcha"));
  62 +
  63 + if (captchaMap.get(userName) != null && captchaMap.get(userName) >= 3) {
  64 + //校验验证码
  65 + String verCode = (String) session
  66 + .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
  67 +
  68 + if (StringUtils.isBlank(captcha))
  69 + return put(rs, "msg", "请输入验证码");
  70 +
  71 + if (!verCode.equals(captcha))
  72 + return put(rs, "msg", "验证码有误,请刷新后重新输入");
  73 + }
  74 +
  75 + //解密RSA
  76 + try {
  77 + userName = RSAUtils.decryptBase64(userName);
  78 + password = RSAUtils.decryptBase64(password);
  79 + } catch (RuntimeException e) {
  80 + return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。");
  81 + }
  82 +
  83 + SysUser user = sysUserService.findByUserName(userName);
  84 + if (null == user)
  85 + return put(rs, "msg", "不存在的用户");
  86 +
  87 + if (!user.isEnabled())
  88 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
  89 +
  90 + // 校验密码
  91 + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
  92 + if (!matchStatus) {
  93 + rs.put("msg", "密码有误");
  94 +
  95 + Integer captchSize = captchaMap.get(userName);
  96 + if (null == captchSize)
  97 + captchSize = 0;
  98 +
  99 + captchSize++;
  100 + captchaMap.put(userName, captchSize);
  101 + return rs;
  102 + }
  103 +
  104 + // 登录
  105 + SecurityUtils.login(user, request);
  106 + //session里写入用户名,webSocket连接时标识身份用
  107 + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
  108 +
  109 + //获取公司权限数据
  110 + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
  111 + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
  112 +
  113 + captchaMap.remove(userName);
  114 + rs.put("status", ResponseCode.SUCCESS);
  115 + } catch (Exception e) {
  116 + logger.error("", e);
  117 + rs.put("msg", "服务器出现异常,请联系管理员");
  118 + }
  119 + return rs;
  120 + }
  121 +
  122 + @RequestMapping(value = "/change_user", method = RequestMethod.POST)
  123 + public Map<String, Object> changeUser(HttpServletRequest request, @RequestParam String userName,
  124 + @RequestParam String password) {
  125 +
  126 + Map<String, Object> rs = new HashMap<>();
  127 + rs.put("status", ResponseCode.ERROR);
  128 + try {
  129 + HttpSession session = request.getSession();
  130 +
  131 + SysUser user = sysUserService.findByUserName(userName);
  132 + if (null == user)
  133 + return put(rs, "msg", "不存在的用户");
  134 +
  135 + if (!user.isEnabled())
  136 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
  137 +
  138 + // 校验密码
  139 + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword());
  140 + if (!matchStatus)
  141 + return put(rs, "msg", "密码有误");
  142 +
  143 + // 登录
  144 + SecurityUtils.login(user, request);
  145 + //session里写入用户名,webSocket连接时标识身份用
  146 + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName());
  147 +
  148 + //获取公司权限数据
  149 + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user);
  150 + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths);
  151 + rs.put("status", ResponseCode.SUCCESS);
  152 + } catch (Exception e) {
  153 + logger.error("", e);
  154 + rs.put("msg", "服务器出现异常,请联系管理员");
  155 + }
  156 + return rs;
  157 + }
  158 +
  159 + /**
  160 + * 返回当前用户的公司权限数据,用于构建页面级联下拉框
  161 + *
  162 + * @return
  163 + */
  164 + @RequestMapping("companyData")
  165 + public List<CompanyData> companyData(HttpServletRequest request) {
  166 + List<CompanyData> rs = new ArrayList<>();
  167 + CompanyData companyData;
  168 +
  169 + ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create();
  170 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS);
  171 +
  172 + for (CompanyAuthority cAuth : cmyAuths) {
  173 + map.put(cAuth.getCompanyCode() + "_" + cAuth.getCompanyName(), cAuth);
  174 + }
  175 +
  176 + Set<String> keys = map.keySet();
  177 + String[] temps;
  178 + for (String k : keys) {
  179 + temps = k.split("_");
  180 +
  181 + companyData = new CompanyData();
  182 + companyData.setCompanyCode(temps[0]);
  183 + companyData.setCompanyName(temps[1]);
  184 + companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>());
  185 +
  186 + cmyAuths = map.get(k);
  187 + for (CompanyAuthority c : cmyAuths) {
  188 + companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName()));
  189 + }
  190 +
  191 + rs.add(companyData);
  192 + }
  193 +
  194 + return rs;
  195 + }
  196 +
  197 + @RequestMapping(value = "/login/captchaStatus")
  198 + public int captchaStatus(String userName) {
  199 + Integer size = captchaMap.get(userName);
  200 + return size == null ? 0 : size;
  201 + }
  202 +
  203 + public Map<String, Object> put(Map<String, Object> rs, String key, Object val) {
  204 + rs.put(key, val);
  205 + return rs;
  206 + }
  207 +
  208 + /**
  209 + * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param
  210 + * request @return String 返回类型 @throws
  211 + */
  212 + @RequestMapping("/loginFailure")
  213 + public String loginFailure(HttpServletRequest request) {
  214 + String msg = "";
  215 + HttpSession session = request.getSession();
  216 +
  217 + Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
  218 +
  219 + if (obj instanceof BadCredentialsException)
  220 + msg = "登录失败,用户名或密码错误.";
  221 + else if (obj instanceof SessionAuthenticationException)
  222 + msg = "登录失败,当前策略不允许重复登录.";
  223 + session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
  224 + return msg;
  225 + }
  226 +
  227 + @RequestMapping("/currentUser")
  228 + public SysUser currentUser() {
  229 + return SecurityUtils.getCurrentUser();
  230 + }
  231 +
  232 + /**
  233 + * @param id 用户ID
  234 + * @param enabled 状态
  235 + * @return
  236 + * @Title changeEnabled
  237 + * @Description: TODO(改变用户状态)
  238 + */
  239 + @RequestMapping("/changeEnabled")
  240 + public int changeEnabled(@RequestParam int id, @RequestParam int enabled) {
  241 + return sysUserService.changeEnabled(id, enabled);
  242 + }
  243 +
  244 + /**
  245 + * @param oldPWD 原始密码
  246 + * @param newPWD 新密码
  247 + * @param cnewPWD 确认新密码
  248 + * @return
  249 + * @Title changePWD
  250 + * @Description: TODO(修改密码)
  251 + */
  252 + @RequestMapping(value = "/changePWD", method = RequestMethod.POST)
  253 + public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) {
  254 + SysUser sysUser = SecurityUtils.getCurrentUser();
  255 + String msg = "";
  256 + if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) {
  257 + if (oldPWD.equals(newPWD)) {
  258 + msg = "新密码不能跟原始密码一样!";
  259 + } else {
  260 + if (newPWD.equals(cnewPWD)) {
  261 + sysUserService.changePWD(sysUser.getId(), newPWD);
  262 + msg = "修改成功!";
  263 + } else {
  264 + msg = "新密码两次输入不一致!";
  265 + }
  266 + }
  267 + } else {
  268 + msg = "原始密码错误!";
  269 + }
  270 + return msg;
  271 + }
  272 +
  273 + @RequestMapping(value = "/register", method = RequestMethod.POST)
  274 + public Map<String, Object> register(SysUser u) {
  275 + return sysUserService.register(u);
  276 + }
  277 +
  278 + @RequestMapping(value = "/all_distinct")
  279 + public List<SysUser> findAll_distinct() {
  280 + return sysUserService.findAll_distinct();
  281 + }
250 282 }
... ...
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java
... ... @@ -48,11 +48,11 @@ public class GpsDataLoaderThread extends Thread {
48 48 //0:从GPS客户端内存获取 -1:从网关获取
49 49 private static int flag = 0;
50 50  
51   - public static void setFlag(int v){
  51 + public static void setFlag(int v) {
52 52 flag = v;
53 53 }
54 54  
55   - public static int getFlag(int v){
  55 + public static int getFlag(int v) {
56 56 return flag;
57 57 }
58 58  
... ... @@ -65,7 +65,7 @@ public class GpsDataLoaderThread extends Thread {
65 65 @Override
66 66 public void run() {
67 67 try {
68   - if(flag == 0)
  68 + if (flag == 0)
69 69 load();
70 70 else
71 71 loadByGateway();
... ... @@ -76,6 +76,7 @@ public class GpsDataLoaderThread extends Thread {
76 76  
77 77 /**
78 78 * 从网关获取实时GPS数据
  79 + *
79 80 * @throws Exception
80 81 */
81 82 public void loadByGateway() throws Exception {
... ... @@ -107,6 +108,9 @@ public class GpsDataLoaderThread extends Thread {
107 108 if (jsonObj != null)
108 109 list = JSON.parseArray(jsonObj.getString("data"), GpsEntity.class);
109 110  
  111 + //过滤掉无效的点位
  112 + list = filterInvalid(list);
  113 +
110 114 String nbbm;
111 115 GpsEntity old;
112 116 for (GpsEntity gps : list) {
... ... @@ -130,7 +134,7 @@ public class GpsDataLoaderThread extends Thread {
130 134 //有更新的点位
131 135 updateList.add(gps);
132 136 }
133   - logger.info("全量点:"+ list.size() +",更新点" + updateList.size());
  137 + logger.info("全量点:" + list.size() + ",更新点" + updateList.size());
134 138 //分析数据
135 139 gpsRealAnalyse.analyse(updateList);
136 140 } else
... ... @@ -146,9 +150,33 @@ public class GpsDataLoaderThread extends Thread {
146 150 }
147 151  
148 152 /**
  153 + * 过滤无效的gps点位
  154 + *
  155 + * @param list
  156 + * @return
  157 + */
  158 + private List<GpsEntity> filterInvalid(List<GpsEntity> list) {
  159 + List<GpsEntity> rsList = new ArrayList<>();
  160 +
  161 + try {
  162 + for (GpsEntity gps : list) {
  163 + if (gps.getValid() == 0)
  164 + rsList.add(gps);
  165 + }
  166 +
  167 + if (rsList.size() < list.size())
  168 + logger.info("过滤无效的点位 : " + (list.size() - rsList.size()));
  169 + } catch (Exception e) {
  170 + logger.error("", e);
  171 + rsList = list;
  172 + }
  173 + return rsList;
  174 + }
  175 +
  176 + /**
149 177 * 从客户端内存获取GPS数据
150 178 */
151   - public void load() throws Exception{
  179 + public void load() throws Exception {
152 180 List<GpsEntity> list = null;
153 181 CloseableHttpClient httpClient = null;
154 182 CloseableHttpResponse response = null;
... ... @@ -174,6 +202,10 @@ public class GpsDataLoaderThread extends Thread {
174 202 stringBuffer.append(str);
175 203  
176 204 list = JSON.parseArray(stringBuffer.toString(), GpsEntity.class);
  205 +
  206 + //过滤掉无效的点位
  207 + list = filterInvalid(list);
  208 +
177 209 String nbbm;
178 210 logger.info("load end!");
179 211 for (GpsEntity gps : list) {
... ...
src/main/java/com/bsth/filter/AccessLogFilter.java
1 1 package com.bsth.filter;
2 2  
3   -import javax.servlet.FilterChain;
4   -import javax.servlet.ServletException;
5   -import javax.servlet.http.HttpServletRequest;
6   -import javax.servlet.http.HttpServletResponse;
7   -
8   -import org.slf4j.Logger;
9   -import org.slf4j.LoggerFactory;
10   -import org.springframework.stereotype.Component;
11   -
12 3 import com.alibaba.fastjson.JSON;
  4 +import com.bsth.entity.sys.SysUser;
13 5 import com.bsth.security.util.SecurityUtils;
14 6 import com.bsth.util.IpUtils;
15 7 import com.google.common.collect.Lists;
16 8 import com.google.common.collect.Maps;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.stereotype.Component;
17 12  
  13 +import javax.servlet.FilterChain;
  14 +import javax.servlet.ServletException;
  15 +import javax.servlet.http.HttpServletRequest;
  16 +import javax.servlet.http.HttpServletResponse;
18 17 import java.io.IOException;
19 18 import java.util.Enumeration;
20 19 import java.util.List;
... ... @@ -38,7 +37,9 @@ public class AccessLogFilter extends BaseFilter {
38 37 HttpServletResponse response, FilterChain chain)
39 38 throws IOException, ServletException {
40 39  
41   - String username = SecurityUtils.getCurrentUser().getName();
  40 + SysUser user = SecurityUtils.getCurrentUser();
  41 + String username = user.getUserName();
  42 + String name = user.getName();
42 43 String jsessionId = request.getRequestedSessionId();
43 44 String ip = IpUtils.getIpAddr(request);
44 45 String userAgent = request.getHeader("User-Agent");
... ... @@ -47,7 +48,7 @@ public class AccessLogFilter extends BaseFilter {
47 48 String headers = getHeaders(request);
48 49  
49 50 StringBuilder s = new StringBuilder();
50   - s.append(getBlock(username));
  51 + s.append(getBlock(username + " -" + name));
51 52 s.append(getBlock(jsessionId));
52 53 s.append(getBlock(ip));
53 54 s.append(getBlock(userAgent));
... ...
src/main/resources/static/pages/control/lineallot_v2/main.html
... ... @@ -283,7 +283,11 @@
283 283 }
284 284 else {
285 285 $(this).addClass('active');
286   - $('.checked_list').append('<span data-id="'+lineCode+'" class="item uk-card uk-card-default uk-animation-slide-bottom">'+name+'</span>');
  286 + var span = $('<span data-id="'+lineCode+'" class="item uk-card uk-card-default uk-animation-slide-bottom">'+name+'</span>')
  287 + .one('webkitAnimationEnd', function () {
  288 + $(this).removeClass('uk-animation-slide-bottom');
  289 + });
  290 + $('.checked_list').append(span);
287 291 }
288 292 });
289 293  
... ...
src/main/resources/static/real_control_v2/css/main.css
... ... @@ -1690,4 +1690,9 @@ dd.disabled{
1690 1690  
1691 1691 dl.active>dd.disabled{
1692 1692 color: #ececec;
  1693 +}
  1694 +
  1695 +#change_user_options-modal .user_info{
  1696 + width: 360px;
  1697 + margin: auto;
1693 1698 }
1694 1699 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task_v2/add_in_out.html
... ... @@ -132,6 +132,7 @@
132 132 $f('reason',inf).val(sch.adjustExps);
133 133 $f('reason',outf).val(sch.adjustExps).trigger('change');
134 134 }
  135 + f.css('z-index', 99);
135 136 }
136 137  
137 138 function $f(name, f) {
... ... @@ -228,24 +229,32 @@
228 229 var htmlStr = template('st-v2-domains-changecar-form-temp', {inOutExps: gb_common.inOutExps});
229 230 $('.domains', half_form).html(htmlStr);
230 231 $('.domains', outf).html(htmlStr);
231   - half_form.css('z-index', 99).formValidation('addField', 'reason').formValidation('addField', 'nbbm');
  232 + half_form/*.css('z-index', 99)*/.formValidation('addField', 'reason').formValidation('addField', 'nbbm');
232 233 outf.trigger('add_reason_field');
233 234  
234 235 //车辆 autocomplete
235 236 var data = gb_data_basic.carsArray();
236 237 gb_common.carAutocomplete($('.autocomplete-cars', half_form), data);
  238 + gb_common.carAutocomplete($('.autocomplete-cars', outf), data);
237 239  
238 240 //同步车辆编码
239 241 $f('nbbm', half_form).on('input change', function () {
240 242 $f('nbbm', outf).val($(this).val());
241 243 });
  244 + $f('nbbm', outf).on('input change', function () {
  245 + $f('nbbm', half_form).val($(this).val());
  246 + });
242 247  
243 248 half_form.removeClass('destroy_form');
244 249  
245 250 //出场终点
246 251 $f('endStation',outf).val($f('endStation',sf).val()).trigger('change');
247   - //发合计公里重新计算
  252 + //发合计公里重新计算
248 253 $f('mileage', half_form).trigger('input');
  254 +
  255 + //调换出场子任务位置
  256 + outf.insertAfter(inf);
  257 + //half_form.insertBefore(outf);
249 258 }
250 259  
251 260 function disabledChangeCar() {
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task_v2/main.html
... ... @@ -10,6 +10,7 @@
10 10 <li name="normal"><a>1、子任务</a></li>
11 11 <li name="in_out"><a>2、进出场</a></li>
12 12 <li name="range_turn"><a>3、区间调头</a></li>
  13 + <li name="range_to_normal"><a>4、区间变全程</a></li>
13 14 </ul>
14 15 </div>
15 16 <div class="uk-width-8-10">
... ... @@ -17,6 +18,7 @@
17 18 <li class="tab_cont normalCont"></li>
18 19 <li class="tab_cont inOutCont"></li>
19 20 <li class="tab_cont rangeTurnCont"></li>
  21 + <li class="tab_cont rangeToNormal"></li>
20 22 </ul>
21 23 </div>
22 24 </div>
... ... @@ -242,6 +244,7 @@
242 244 //区间调头
243 245 $('.rangeTurnCont', modal).html(st_doms.range_dom);
244 246 $('.add_range_wrap', modal).trigger('init', data);
  247 + //区间变全程
245 248 }
246 249 });
247 250  
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/user_change/user_change_modal.html 0 → 100644
  1 +<div class="uk-modal ct-form-modal" id="change_user_options-modal">
  2 + <div class="uk-modal-dialog">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <h2>切换账号/模式</h2>
  5 +
  6 + <div class="user_info">
  7 + <form class="uk-form uk-form-horizontal">
  8 +
  9 + <div class="uk-form-row">
  10 + <label class="uk-form-label" for="form-h-it">用户名</label>
  11 + <div class="uk-form-controls">
  12 + <input name="userName" type="text" id="form-h-it" value="" autocomplete="off">
  13 + </div>
  14 + </div>
  15 + <div class="uk-form-row">
  16 + <label class="uk-form-label" for="form-h-ip">密码</label>
  17 + <div class="uk-form-controls">
  18 + <input name="password" type="password" id="form-h-ip" value="******" disabled
  19 + autocomplete="off">
  20 + </div>
  21 + </div>
  22 + <div class="uk-form-row">
  23 + <label class="uk-form-label" for="form-h-s">调度模式</label>
  24 + <div class="uk-form-controls">
  25 + <select id="form-h-s" name="operationMode">
  26 + <option value="1">主调模式</option>
  27 + <option value="0">监控模式</option>
  28 + </select>
  29 + </div>
  30 + </div>
  31 + <br>
  32 + <div class="uk-form-row">
  33 + <button disabled class="uk-button uk-button-danger uk-button-large uk-width-1-1 confirm_btn"
  34 + type="button">
  35 + 确认切换
  36 + </button>
  37 + </div>
  38 + </form>
  39 + </div>
  40 + </div>
  41 +
  42 + <script>
  43 + (function () {
  44 + var modal = '#change_user_options-modal',
  45 + user = gb_northToolbar.user(),
  46 + operationMode = window.localStorage.getItem('operationMode'),
  47 + f = $('.user_info>form', modal);
  48 + //用户名
  49 + $('input[name=userName]', f).val(user.userName)
  50 + .on('input', function () {
  51 + //清除密码
  52 + $('input[name=password]', f).val('').removeAttr('disabled');
  53 + changeBtnStatus();
  54 + });
  55 +
  56 + //密码
  57 + $('input[name=password]', f).on('input', changeBtnStatus);
  58 +
  59 + //切换模式
  60 + $('select[name=operationMode]', f).val(operationMode).on('change', changeBtnStatus);
  61 +
  62 + var confirmBtn = $('.confirm_btn', f);
  63 +
  64 + function changeBtnStatus() {
  65 + var data = f.serializeJSON();
  66 + if ((data.userName != user.userName && $.trim(data.password))
  67 + || data.operationMode != operationMode)
  68 + confirmBtn.removeAttr('disabled');
  69 + else {
  70 + confirmBtn.attr('disabled', 'disabled');
  71 + if (data.userName == user.userName)
  72 + $('input[name=password]', f).val('******').attr('disabled', 'disabled');
  73 + }
  74 + }
  75 +
  76 + //确认切换
  77 + $('.confirm_btn', f).on('click', function () {
  78 + $(this).attr('disabled', 'disabled');
  79 +
  80 + var data = f.serializeJSON();
  81 + if (data.userName != user.userName) {
  82 + //切换账号
  83 + if (!$.trim(data.password))
  84 + return notify_err('密码不能为空!');
  85 +
  86 + gb_common.$post('/user/change_user', data, function (rs) {
  87 + notify_succ('切换账号成功!');
  88 + gb_northToolbar.init();
  89 + gb_delay_write_log();//当班调度日志
  90 + });
  91 + }
  92 +
  93 + if(data.operationMode != operationMode){
  94 + window.localStorage.setItem('operationMode', data.operationMode);
  95 + //切换调度模式
  96 + gb_dp_initHttpIntercept();
  97 + }
  98 +
  99 + UIkit.modal(modal).hide();
  100 + });
  101 + })();
  102 + </script>
  103 +</div>
... ...
src/main/resources/static/real_control_v2/fragments/north/toolbar.html
... ... @@ -2,7 +2,7 @@
2 2 <script id="north-toolbar-temp" type="text/html">
3 3 <div class="uk-margin" id="north_toolbar_panel">
4 4 <nav class="uk-navbar">
5   - <a class="uk-navbar-brand" id="navbar_user_detail_link">
  5 + <a class="uk-navbar-brand" id="navbar_user_detail_link" title="点击切换账号">
6 6 <span><i class="uk-icon-user"></i> <span id="north_toolbar_user">{{user.userName}}</span></span><i class="uk-icon-ellipsis-v"></i>
7 7 </a>
8 8 <ul class="uk-navbar-nav">
... ...
src/main/resources/static/real_control_v2/js/data/data_gps.js
... ... @@ -22,6 +22,8 @@ var gb_data_gps = (function () {
22 22 success: function (rs) {
23 23 //用定时的gps来检测session断开
24 24 if(rs.status && rs.status==407){
  25 + //解除退出页面的提示框
  26 + window.removeEventListener("beforeunload", gb_beforeunload_fun);
25 27 location.href = '/login.html';
26 28 return;
27 29 }
... ...
src/main/resources/static/real_control_v2/js/main.js
... ... @@ -59,7 +59,6 @@ var gb_main_ep = new EventProxy(),
59 59 }
60 60 });
61 61  
62   -
63 62 $(document).on('click', '.ct-bottom-drawer-close', function () {
64 63 $(this).parents('.ct-bottom-drawer').removeClass('open');
65 64 });
... ...
src/main/resources/static/real_control_v2/js/north/toolbar.js
... ... @@ -5,97 +5,59 @@ var gb_northToolbar = (function () {
5 5 var modal_opts = {center: true, bgclose: false};
6 6 var currentUser;
7 7  
8   - $.get('/real_control_v2/fragments/north/toolbar.html', function (temp) {
9   - ep.emit("template", temp);
10   - });
  8 + var init = function () {
  9 + $.get('/real_control_v2/fragments/north/toolbar.html', function (temp) {
  10 + ep.emit("template", temp);
  11 + });
11 12  
12   - $.get('/real_control_v2/js/data/json/north_toolbar.json', function (data) {
13   - ep.emit("data", data);
14   - });
  13 + $.get('/real_control_v2/js/data/json/north_toolbar.json', function (data) {
  14 + ep.emit("data", data);
  15 + });
15 16  
16   - //当前用户信息
17   - $.get('/user/currentUser', function (user) {
18   - ep.emit("user", user);
  17 + //当前用户信息
  18 + $.get('/user/currentUser', function (user) {
  19 + ep.emit("user", user);
19 20  
20   - //查询线调权限信息
21   - $.get('/realControAuthority/findByUserId', {userId: user.id}, function (rs) {
22   - ep.emit("xd_auth", rs);
  21 + //查询线调权限信息
  22 + $.get('/realControAuthority/findByUserId', {userId: user.id}, function (rs) {
  23 + ep.emit("xd_auth", rs);
  24 + });
23 25 });
24   - });
25 26  
26   - var xd_auth;//线调权限
27   - var ep = EventProxy.create("template", "data", "user", 'xd_auth', function (temp, data, user, auth) {
28   - var tempId = '#north-toolbar-temp';
29   - xd_auth = auth;
30   - //electron环境
31   - if(isElectron){
32   - tempId = '#north-toolbar-electron-temp';
33   - //最小化
34   - $(document).on('click', '#mnavbarIconBtnMIN', function () {
35   - ipcMain.send('webPageMainWindowMinimize');
36   - });
37   - //关闭
38   - $(document).on('click', '#mnavbarIconBtnCLOSE', function () {
39   - ipcMain.send('webPageMainWindowClose');
  27 + var xd_auth;//线调权限
  28 + var ep = EventProxy.create("template", "data", "user", 'xd_auth', function (temp, data, user, auth) {
  29 + var tempId = '#north-toolbar-temp';
  30 + xd_auth = auth;
  31 + currentUser = user;
  32 + var t = $(tempId, temp).html()
  33 + , htmlStr = template.render(t)({list: data, user: currentUser});
  34 + $('.north .north-toolbar').html(htmlStr);
  35 +
  36 + //exit
  37 + $('.north .north-toolbar .exit-system').on('click', function () {
  38 + //关闭websocket 连接
  39 + gb_sch_websocket.sock().close(1000, '退出线调');
  40 + window.location.href = '/pages/control/lineallot_v2/iframe_wrap.html';
40 41 });
41   - }
42   - currentUser = user;
43   - var t = $(tempId, temp).html()
44   - , htmlStr = template.render(t)({list: data, user: currentUser});
45   - $('.north .north-toolbar').html(htmlStr);
46 42  
47   - //exit
48   - $('.north .north-toolbar .exit-system').on('click', function () {
49   - //关闭websocket 连接
50   - gb_sch_websocket.sock().close(1000, '退出线调');
51   - window.location.href = '/pages/control/lineallot_v2/iframe_wrap.html';
  43 + //过滤菜单
  44 + var excludes=[];
  45 + if(xd_auth.excludeMenus)
  46 + excludes=xd_auth.excludeMenus.split(',');
  47 + if(excludes.length>0){
  48 + $('li.event', '#north_toolbar_panel').each(function () {
  49 + if(excludes.indexOf($('a', this).data('event'))!=-1)
  50 + $(this).remove();
  51 + });
  52 + }
52 53 });
  54 + };
53 55  
54   - //console.log('xd_auth', xd_auth, 'data', data);
55   - //过滤菜单
56   - var excludes=[];
57   - if(xd_auth.excludeMenus)
58   - excludes=xd_auth.excludeMenus.split(',');
59   - if(excludes.length>0){
60   - $('li.event', '#north_toolbar_panel').each(function () {
61   - if(excludes.indexOf($('a', this).data('event'))!=-1)
62   - $(this).remove();
63   - });
64   - }
65   -
66   - //鼠标悬停用户名
67   -/* $(document).on('mouseenter', '#navbar_user_detail_link', function() {
68   - $(this).qtip({
69   - show: {
70   - ready: true,
71   - delay: 300
72   - },
73   - content: {
74   - text: function() {
  56 + init();
75 57  
76   - return '';//temps['sch-table-task-tootip-temp']({tasks: array});
77   - }
78   - },
79   - position: {
80   - viewport: $(window),
81   - my: 'top center',
82   - at: 'bottom center'
83   - },
84   - style: {
85   - classes: 'qtip-light qtip-shadow user_detail_tip'
86   - },
87   - hide: {
88   - fixed: true,
89   - delay: 300
90   - },
91   - events: {
92   - hidden: function(event, api) {
93   - //destroy dom
94   - $(this).qtip('destroy', true);
95   - }
96   - }
97   - });
98   - });*/
  58 + //点击用户名
  59 + $(document).on('click', '#navbar_user_detail_link', function () {
  60 + open_modal('/real_control_v2/fragments/north/nav/user_change/user_change_modal.html', {}, {center: false, bgclose: false});
99 61 });
100 62  
101 63 $(document).on('click', '#north_toolbar_panel li.event a', function () {
... ... @@ -103,6 +65,19 @@ var gb_northToolbar = (function () {
103 65 handler[event] && handler[event]();
104 66 });
105 67  
  68 + //electron环境
  69 + if(isElectron){
  70 + tempId = '#north-toolbar-electron-temp';
  71 + //最小化
  72 + $(document).on('click', '#mnavbarIconBtnMIN', function () {
  73 + ipcMain.send('webPageMainWindowMinimize');
  74 + });
  75 + //关闭
  76 + $(document).on('click', '#mnavbarIconBtnCLOSE', function () {
  77 + ipcMain.send('webPageMainWindowClose');
  78 + });
  79 + }
  80 +
106 81 var handler = {
107 82 // device report list
108 83 device_report: function () {
... ... @@ -254,6 +229,7 @@ var gb_northToolbar = (function () {
254 229 return {
255 230 user: function () {
256 231 return currentUser;
257   - }
  232 + },
  233 + init: init
258 234 }
259 235 })();
... ...
src/main/resources/static/real_control_v2/js/utils/dispatch_pattern.js
1 1 /** 调度模式 */
2 2  
3   -//主调和监控模式
4   -var operationMode = window.localStorage.getItem('operationMode');
5   -if (operationMode == 0) {
6   - $('body>.north').addClass('monitor');
7   - $(document).on('ajaxSend', interceptPOST);
8   -}
9   -else
10   - $('body>.north').addClass('main');
  3 +var gb_dp_initHttpIntercept = function () {
  4 + //主调和监控模式
  5 + var operationMode = window.localStorage.getItem('operationMode');
  6 + $(document).off('ajaxSend', interceptPOST);
  7 + $('body>.north').removeClass('monitor main');
  8 + if (operationMode == 0) {
  9 + $('body>.north').addClass('monitor');
  10 + $(document).on('ajaxSend', interceptPOST);
  11 + }
  12 + else
  13 + $('body>.north').addClass('main');
  14 +
  15 +};
  16 +//10分钟后提交当班调度数据
  17 +var gb_delay_write_log = function () {
  18 + setTimeout(function () {
  19 + var user = gb_northToolbar.user();
  20 + var data = {
  21 + uId: user.id,
  22 + uName: user.userName,
  23 + codeIdx: gb_data_basic.line_idx + ',',
  24 + main: operationMode
  25 + };
  26 +
  27 + gb_common.$post('/dutyEmployee', data);
  28 + }, 1000 * 60 * 10);
  29 +};
  30 +
  31 +gb_dp_initHttpIntercept();
  32 +gb_delay_write_log();
11 33  
12 34 //拦截POST请求
13 35 function interceptPOST(e, xhr, t) {
... ... @@ -19,21 +41,7 @@ function interceptPOST(e, xhr, t) {
19 41  
20 42 //全局 ajaxError 事件
21 43 $(document).ajaxError(function (event, jqxhr) {
22   - if(jqxhr.status == 403){
  44 + if (jqxhr.status == 403) {
23 45 UIkit.modal.alert('<span style="color: red;">访问被拒绝,你没有这个权限!</span>', {labels: {Ok: '确定'}});
24 46 }
25 47 });
26   -
27   -
28   -//10分钟后提交当班调度数据
29   -setTimeout(function () {
30   - var user = gb_northToolbar.user();
31   - var data = {
32   - uId: user.id,
33   - uName: user.userName,
34   - codeIdx: gb_data_basic.line_idx + ',',
35   - main: operationMode
36   - };
37   -
38   - gb_common.$post('/dutyEmployee', data);
39   -}, 1000 * 60 * 10);
40 48 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/main.html
... ... @@ -74,6 +74,13 @@
74 74 </div>
75 75  
76 76 <script>
  77 + var gb_beforeunload_fun = function (e) {
  78 + var confirmationMessage = "\o/";
  79 + (e || window.event).returnValue = confirmationMessage;
  80 + return confirmationMessage;
  81 + }
  82 + window.addEventListener("beforeunload", gb_beforeunload_fun);
  83 +
77 84 delete window.exports;
78 85 delete window.module;
79 86  
... ...