Commit b4523739ca7f897cc74b0576edfbf66b73df92e5

Authored by 游瑞烽
1 parent 4de482d2

1.权限管理模块配置,严格的树形结构管理权限。 2.上传ftp存线路文件版本表 3.生成双路段改"()"

src/main/java/com/bsth/controller/sys/RoleController.java
1 1 package com.bsth.controller.sys;
2 2  
  3 +import java.util.Iterator;
3 4 import java.util.Map;
4 5  
  6 +import com.bsth.entity.sys.SysUser;
  7 +import com.bsth.security.util.SecurityUtils;
5 8 import org.springframework.beans.factory.annotation.Autowired;
6 9 import org.springframework.web.bind.annotation.RequestMapping;
7 10 import org.springframework.web.bind.annotation.RequestMethod;
... ... @@ -19,6 +22,27 @@ public class RoleController extends BaseController<Role, Integer>{
19 22  
20 23 @Autowired
21 24 RoleService roleService;
  25 +
  26 + /**
  27 + * @param @param map
  28 + * @throws
  29 + * @Title: list
  30 + * @Description: TODO(查询下级)
  31 + */
  32 + @RequestMapping(value = "/findSubordinate", method = RequestMethod.GET)
  33 + public Map<String, Object> findSubordinate() {
  34 + return roleService.findSubordinate();
  35 + }
  36 +
  37 + /**
  38 + * @param @param map
  39 + * @Description: TODO(添加角色)
  40 + * @return
  41 + */
  42 + @RequestMapping(value = "/add", method = RequestMethod.POST)
  43 + public Map<String, Object> add(Role role){
  44 + return roleService.add(role);
  45 + }
22 46  
23 47 /**
24 48 *
... ...
src/main/java/com/bsth/controller/sys/UserController.java
... ... @@ -47,6 +47,12 @@ public class UserController extends BaseController&lt;SysUser, Integer&gt; {
47 47 return rs;
48 48 }
49 49  
  50 + @RequestMapping(value = "/getCurrentUser")
  51 + public SysUser getCurrentUser() {
  52 + SysUser user = SecurityUtils.getCurrentUser();
  53 + return user;
  54 + }
  55 +
50 56 //需要验证码的账号
51 57 public static Map<String, Integer> captchaMap = new HashMap<>();
52 58  
... ...
src/main/java/com/bsth/entity/sys/Role.java
... ... @@ -14,6 +14,7 @@ import javax.persistence.ManyToMany;
14 14 import javax.persistence.Table;
15 15  
16 16 import com.fasterxml.jackson.annotation.JsonIgnore;
  17 +import org.hibernate.annotations.Formula;
17 18  
18 19 @Entity
19 20 @Table(name = "bsth_c_sys_role")
... ... @@ -50,7 +51,28 @@ public class Role {
50 51  
51 52 @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
52 53 private Date updateDate;
53   -
  54 +
  55 + /**
  56 + * 角色权限
  57 + *
  58 + * 角色树结构 本级只能管理下级角色,不能查看同级和上级的任何数据:这里主要为了规范管理 (管理员)层级的用户
  59 + *
  60 + * 只能看其他角色upCode 等于 本角色roleCode level字段等级比自己小的 其他角色 严格的树形结构,只能看自己分支下级节点
  61 + *
  62 + */
  63 + private int roleCode;
  64 +
  65 + private int upCode;
  66 +
  67 + private int level;
  68 +
  69 + /** 组合自己和父节点编码 */
  70 + @Formula(" concat(up_code, '_', role_code) ")
  71 + private String groupCode;
  72 +
  73 + @Formula(" concat(level, '_',role_code) ")
  74 + private String levelCode;
  75 +
54 76 private int pic;
55 77  
56 78 public Integer getId() {
... ... @@ -141,6 +163,47 @@ public class Role {
141 163 this.codeName = codeName;
142 164 }
143 165  
  166 + public int getRoleCode() {
  167 + return roleCode;
  168 + }
  169 +
  170 + public void setRoleCode(int roleCode) {
  171 + this.roleCode = roleCode;
  172 + }
  173 +
  174 + public int getUpCode() {
  175 + return upCode;
  176 + }
  177 +
  178 + public void setUpCode(int upCode) {
  179 + this.upCode = upCode;
  180 + }
  181 +
  182 + public int getLevel() {
  183 + return level;
  184 + }
  185 +
  186 + public void setLevel(int level) {
  187 + this.level = level;
  188 + }
  189 +
  190 + public String getGroupCode() {
  191 + return groupCode;
  192 + }
  193 +
  194 + public void setGroupCode(String groupCode) {
  195 + this.groupCode = groupCode;
  196 + }
  197 +
  198 +
  199 + public String getLevelCode() {
  200 + return levelCode;
  201 + }
  202 +
  203 + public void setLevelCode(String levelCode) {
  204 + this.levelCode = levelCode;
  205 + }
  206 +
144 207 public int getPic() {
145 208 return pic;
146 209 }
... ...
src/main/java/com/bsth/repository/LineRepository.java
... ... @@ -68,4 +68,33 @@ public interface LineRepository extends BaseRepository&lt;Line, Integer&gt; {
68 68 String shortName, String shanghaiLinecode, String eqLinecode, String startPhone, String endPhone,
69 69 Integer carSumNumber, Integer hvacCarNumber, Integer ordCarNumber, String history, String descriptions,
70 70 Integer destroy, Integer supperLine, Integer spacGrade, Integer warrantCar, String lineCode, Integer region);
  71 +
  72 + /**
  73 + * 查询线路版本文件
  74 + * @param lineId
  75 + * @return
  76 + */
  77 + @Query(value = "SELECT version_count FROM bsth_c_line_file_version where line = ?1", nativeQuery = true)
  78 + Integer findfileVersions(Integer lineId);
  79 +
  80 + /**
  81 + * 添加线路文件版本
  82 + * @param lineId
  83 + * @param line_code
  84 + */
  85 + @Transactional
  86 + @Modifying
  87 + @Query(value = "INSERT INTO bsth_c_line_file_version (line,line_code,version_count) VALUES (?1,?2,1)", nativeQuery = true)
  88 + public void addFileVersions(Integer lineId, String line_code);
  89 +
  90 + /**
  91 + * 线路文件版本修改
  92 + * @param lineId
  93 + * @param version_count
  94 + */
  95 + @Transactional
  96 + @Modifying
  97 + @Query(value = "UPDATE bsth_c_line_file_version set version_count=?2 WHERE line = ?1", nativeQuery = true)
  98 + public void editFileVersions(Integer lineId, Integer version_count);
  99 +
71 100 }
... ...
src/main/java/com/bsth/repository/sys/RoleRepository.java
... ... @@ -16,6 +16,11 @@ import java.util.List;
16 16 @Repository
17 17 public interface RoleRepository extends BaseRepository<Role, Integer>{
18 18  
  19 + // 查询最大ID
  20 + @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_sys_role) k"
  21 + , nativeQuery=true)
  22 + public int roleMaxId();
  23 +
19 24 /**
20 25 * @Title: update
21 26 * @Description: TODO(简洁版更新(不需要级联的))
... ... @@ -27,4 +32,7 @@ public interface RoleRepository extends BaseRepository&lt;Role, Integer&gt;{
27 32  
28 33 @Query(value = "select * from role where id in(?1)",nativeQuery = true)
29 34 List<Role> findAllById(String ids);
  35 +
  36 +// @Query(value = "select r from Role r where < ?1")
  37 +// List<Role> findSubordinate(Integer pic);
30 38 }
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
... ... @@ -756,9 +756,17 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
756 756 try {
757 757 // 获取线路ID
758 758 Integer lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString());
759   - Integer fileVersions = map.get("fileVersions").equals("") ? 2 : Integer.parseInt(map.get("fileVersions").toString());// 没有输入就默认2
760 759 /** 查询线路信息 @param:<lineId:线路ID> */
761 760 Line line = lineRepository.findOne(lineId);
  761 + Integer fileVersions = lineRepository.findfileVersions(lineId);
  762 + if(fileVersions == null) {
  763 + lineRepository.addFileVersions(line.getId(), line.getLineCode());
  764 + fileVersions = 1;
  765 + } else {
  766 + fileVersions = fileVersions + 1;
  767 + lineRepository.editFileVersions(line.getId(),fileVersions);
  768 + }
  769 +// Integer fileVersions = map.get("fileVersions").equals("") ? 1 : Integer.parseInt(map.get("fileVersions").toString());// 没有输入就默认1
762 770 /** 查询线路信息下的站点路由信息 @param:<lineId:线路ID> */
763 771 List<Object[]> objects = repository.usingSingle(lineId);
764 772 if (objects.size()>0) {
... ... @@ -814,8 +822,9 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
814 822 } catch (Exception e) {
815 823 resultMap.put("status", ResponseCode.ERROR);
816 824 logger.error("save erro.", e);
  825 + } finally {
  826 + return resultMap;
817 827 }
818   - return resultMap;
819 828 }
820 829 // 判断线路走向是环线还是双向
821 830 public boolean ishxType(List<Object[]> listObj) {
... ...
src/main/java/com/bsth/service/impl/StationServiceImpl.java
... ... @@ -294,22 +294,24 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
294 294 /*Integer stationId = Integer.parseInt(stationNameList.get(0)[1].toString());*/
295 295 Integer stationId = Integer.parseInt(isHaveMap.get("id").toString());
296 296 arg0 = repository.findOne(stationId);
297   -
  297 +
298 298 if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
299 299 arg0 = loopStartStation;
300 300 } else {
301 301 List<Station> list = new ArrayList<>();
302 302 list.add(arg0);
303 303 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
304   - Station station = stationlist.get(0);
  304 + Station station = stationlist.get(0);
305 305 // 站点编码
306 306 long stationCode = GetUIDAndCode.getStationId();
307 307 station.setStationCod(String.valueOf(stationCode));
308 308 station.setId((int)stationCode);
309 309 station.setCreateDate(null);
310 310 station.setUpdateDate(null);
  311 + station.setShapesType("r");
  312 + station.setRadius(80);
311 313 repository.save(station);
312   - arg0 = station;
  314 + arg0 = station;
313 315 if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
314 316 loopStartStation = arg0;
315 317 }
... ... @@ -330,13 +332,13 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
330 332 if(baseRes.equals("No")){
331 333 /** BD to WGS坐标 */
332 334 resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
333   - if(gLonxStr==null)
  335 + if(gLonxStr==null)
334 336 gLonx = (float)resultPoint.getLng();
335   - else
  337 + else
336 338 gLonx = Float.valueOf(gLonxStr);
337 339 if(gLatyStr==null)
338 340 gLaty = (float)resultPoint.getLat();
339   - else
  341 + else
340 342 gLaty = Float.valueOf(gLatyStr);
341 343 arg0.setgLonx(gLonx);
342 344 arg0.setgLaty(gLaty);
... ... @@ -362,12 +364,12 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
362 364 Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
363 365 Location gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
364 366 Location bdEn = TransGPS.bd_encrypt(gcjLoc);
365   - bJwpoints = String.valueOf(bdEn.getLng()) + " " + String.valueOf(bdEn.getLat());
  367 + bJwpoints = String.valueOf(bdEn.getLng()) + " " + String.valueOf(bdEn.getLat());
366 368 arg0.setbJwpoints(bJwpoints);
367 369 arg0.setgLonx(Float.valueOf(gLonxStr));
368 370 arg0.setgLaty(Float.valueOf(gLatyStr));
369 371 }
370   - arg0.setRadius(radius);
  372 + arg0.setRadius(80);
371 373 arg0.setShapesType(shapesType);
372 374 // 是否想撤销
373 375 arg0.setDestroy(destroy);
... ... @@ -383,7 +385,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
383 385 } else {
384 386 repository.save(arg0);
385 387 }
386   -
  388 +
387 389 }
388 390 // 站点路由对象
389 391 StationRoute route = new StationRoute();
... ... @@ -1508,35 +1510,78 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1508 1510 //Map<String, Object> isHaveMap = isHaveStationname(bLonx,bLatx,stationNameList);
1509 1511 // 初始化站点对象
1510 1512 Station arg0 = new Station();
  1513 + // 站点编码
  1514 + long stationCode = GetUIDAndCode.getStationId();
  1515 + arg0.setStationCod(String.valueOf(stationCode));
  1516 + arg0.setId((int)stationCode);
1511 1517 // 存在的点就不添加到数据库(起终点站重新添加站点)
1512 1518 if(Boolean.parseBoolean(stationsArray.getJSONObject(i).get("isHave").toString())) {
1513 1519 Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString());
1514   - arg0 = repository.findOne(stationId);
1515   -
  1520 + Station station = repository.findOne(stationId);
  1521 + arg0.setDbType(dbType);
  1522 + String gLonxStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("x").toString();
  1523 + String gLatyStr = JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").equals("") ? null : JSONObject.parseObject(stationsArray.getJSONObject(i).get("wgs").toString()).get("y").toString();
  1524 + float gLonx = 0.0f;
  1525 + float gLaty = 0.0f;
  1526 + Location resultPoint = null;
  1527 + if(baseRes.equals("No")){
  1528 + /** BD to WGS坐标 */
  1529 + resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
  1530 + if(gLonxStr==null)
  1531 + gLonx = (float)resultPoint.getLng();
  1532 + else
  1533 + gLonx = Float.valueOf(gLonxStr);
  1534 + if(gLatyStr==null)
  1535 + gLaty = (float)resultPoint.getLat();
  1536 + else
  1537 + gLaty = Float.valueOf(gLatyStr);
  1538 + arg0.setgLonx(gLonx);
  1539 + arg0.setgLaty(gLaty);
  1540 + // 百度经纬度
  1541 + bJwpoints = bLonx + " " + bLatx;
  1542 + arg0.setbJwpoints(bJwpoints);
  1543 + }else if(baseRes.equals("GCJ02")){
  1544 + Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
  1545 + Location location = TransGPS.bd_encrypt(bdLoc);
  1546 + String GCJLng = String.valueOf(location.getLng());
  1547 + String GCJLat = String.valueOf(location.getLat());
  1548 + resultPoint = FromBDPointToWGSPoint(GCJLng,GCJLat);
  1549 + bJwpoints = GCJLng + " " +GCJLat;
  1550 + arg0.setgLonx((float)location.getLng());
  1551 + arg0.setgLaty((float)location.getLat());
  1552 + arg0.setbJwpoints(bJwpoints);
  1553 + }else if(baseRes.equals("BD09")){
  1554 + resultPoint = FromBDPointToWGSPoint(gLonxStr, gLatyStr);
  1555 + bJwpoints = gLonxStr+ " " + gLatyStr;
  1556 + arg0.setgLonx((float)resultPoint.getLng());
  1557 + arg0.setgLaty((float)resultPoint.getLat());
  1558 + }else if(baseRes.equals("WGS84")){
  1559 + Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
  1560 + Location gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
  1561 + Location bdEn = TransGPS.bd_encrypt(gcjLoc);
  1562 + bJwpoints = String.valueOf(bdEn.getLng()) + " " + String.valueOf(bdEn.getLat());
  1563 + arg0.setbJwpoints(bJwpoints);
  1564 + arg0.setgLonx(Float.valueOf(gLonxStr));
  1565 + arg0.setgLaty(Float.valueOf(gLatyStr));
  1566 + }
  1567 + arg0.setRadius(radius);
  1568 + arg0.setShapesType(shapesType);
  1569 + // 是否想撤销
  1570 + arg0.setDestroy(destroy);
  1571 + // 版本号
  1572 + arg0.setVersions(versions);
  1573 + arg0.setbJwpoints(bJwpoints);
  1574 + // 引用查到站点的名字
  1575 + arg0.setStationName(station.getStationName());
1516 1576 if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1517 1577 arg0 = loopStartStation;
1518 1578 } else {
1519   - List<Station> list = new ArrayList<>();
1520   - list.add(arg0);
1521   - List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
1522   - Station station = stationlist.get(0);
1523   - // 站点编码
1524   - long stationCode = GetUIDAndCode.getStationId();
1525   - station.setStationCod(String.valueOf(stationCode));
1526   - station.setId((int)stationCode);
1527   - station.setCreateDate(null);
1528   - station.setUpdateDate(null);
1529   - repository.save(station);
1530   - arg0 = station;
  1579 + repository.save(arg0);
1531 1580 if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
1532 1581 loopStartStation = arg0;
1533 1582 }
1534 1583 }
1535 1584 }else {
1536   - // 站点编码
1537   - long stationCode = GetUIDAndCode.getStationId();
1538   - arg0.setStationCod(String.valueOf(stationCode));
1539   - arg0.setId((int)stationCode);
1540 1585 arg0.setStationName(stationName);
1541 1586 // 原坐标类型
1542 1587 arg0.setDbType(dbType);
... ...
src/main/java/com/bsth/service/sys/RoleService.java
... ... @@ -4,10 +4,15 @@ import java.util.List;
4 4 import java.util.Map;
5 5  
6 6 import com.bsth.entity.sys.Role;
  7 +import com.bsth.entity.sys.SysUser;
7 8 import com.bsth.service.BaseService;
8 9  
9 10 public interface RoleService extends BaseService<Role, Integer>{
10 11  
  12 + Map<String, Object> findSubordinate();
  13 +
  14 + Map<String, Object> add(Role role);
  15 +
11 16 Map<String, Object> settRoleModules(Integer roleId, String mIds);
12 17  
13 18 Map<String, Object> roleInfo(Integer id);
... ...
src/main/java/com/bsth/service/sys/impl/RoleServiceImpl.java
1 1 package com.bsth.service.sys.impl;
2 2  
  3 +import java.beans.BeanInfo;
  4 +import java.beans.Introspector;
  5 +import java.beans.PropertyDescriptor;
  6 +import java.lang.reflect.Method;
3 7 import java.text.SimpleDateFormat;
4   -import java.util.ArrayList;
5   -import java.util.HashMap;
6   -import java.util.Iterator;
7   -import java.util.List;
8   -import java.util.Map;
9   -import java.util.Set;
  8 +import java.util.*;
10 9  
  10 +import com.bsth.security.util.SecurityUtils;
  11 +import com.bsth.util.TreeUtil;
  12 +import org.antlr.runtime.tree.Tree;
11 13 import org.slf4j.Logger;
12 14 import org.slf4j.LoggerFactory;
13 15 import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
14 17 import org.springframework.stereotype.Service;
15 18  
16 19 import com.bsth.common.ResponseCode;
... ... @@ -37,6 +40,180 @@ public class RoleServiceImpl extends BaseServiceImpl&lt;Role, Integer&gt; implements
37 40 SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
38 41  
39 42 @Override
  43 + public Map<String, Object> findSubordinate() {
  44 + SysUser user = SecurityUtils.getCurrentUser();
  45 + Iterator<Role> itRole = user.getRoles().iterator();
  46 + Role ro = new Role();
  47 + while(itRole.hasNext()){//判断是否有下一个
  48 + ro = itRole.next();
  49 + }
  50 + Map<String, Object> map = new HashMap<>();
  51 + List<Map<String, Object>> rsRoleList = new ArrayList<>();
  52 + try {
  53 + // 读取层次数据结果集列表
  54 + Iterator<Role> roleList = roleRepository.findAll().iterator();
  55 +
  56 + // 节点列表(散列表,用于临时存储节点对象)
  57 + Map<String, Object> nodeList = new HashMap<>();
  58 + // 根节点
  59 + List rootlist = new ArrayList();
  60 + while(roleList.hasNext()){
  61 + Role role = roleList.next();
  62 + HashMap map0 = new HashMap();
  63 + map0.put("id", role.getId());
  64 + map0.put("roleCode", role.getRoleCode());
  65 + map0.put("upCode", role.getUpCode());
  66 + map0.put("roleName", role.getRoleName());
  67 + map0.put("codeName", role.getCodeName());
  68 + map0.put("level", role.getLevel());
  69 + map0.put("levelCode", role.getLevelCode());
  70 + nodeList.put(role.getLevelCode(), map0);
  71 + }
  72 + // 构造无序的多叉树
  73 + Set entrySet = nodeList.entrySet();
  74 + for (Iterator it = entrySet.iterator(); it.hasNext();) {
  75 + Map<String, Object> map1 = (HashMap) ((Map.Entry) it.next()).getValue();
  76 +// Map<String, Object> map1 = objectToMap(it.next());
  77 + if (map1.get("upCode") == null || map1.get("upCode").equals("")
  78 + || Integer.parseInt(map1.get("upCode").toString()) == 0) {
  79 + // root = node;
  80 + rootlist.add(map1);
  81 + } else {
  82 + Map<String, Object> tempmap = ((HashMap)nodeList.get((Integer.parseInt(map1.get("level").toString())-1)+"_"+map1.get("upCode")));
  83 +// Map<String, Object> tempmap = objectToMap(nodeList.get((Integer.parseInt(map1.get("level").toString())-1)+"_"+map1.get("upCode")));
  84 + System.out.println(tempmap);
  85 +
  86 + List templist = (List) tempmap.get("children");
  87 + if (null != templist) {
  88 + templist.add(map1);
  89 + } else {
  90 + templist = new ArrayList();
  91 + templist.add(map1);
  92 + }
  93 + tempmap.put("children", templist);
  94 + }
  95 + }
  96 + getRoleList(rootlist,ro.getLevelCode(),rsRoleList,false);
  97 +
  98 + // 排序后输出
  99 +// ComparatorSysrole(rootlist);
  100 + map.put("list", rsRoleList);
  101 + map.put("status", ResponseCode.SUCCESS);
  102 + } catch (Exception e) {
  103 + map.put("status", ResponseCode.ERROR);
  104 + logger.error("error",e);
  105 + }
  106 + return map;
  107 + }
  108 +
  109 + private void getRoleList(List<Map<String, Object>> list, String levelCode, List<Map<String, Object>> roleList,boolean isChildren){
  110 + try{
  111 + if(isChildren){
  112 + for (Map<String, Object> map : list) {
  113 + roleList.add(map);
  114 + List mapList = (List) map.get("children");
  115 + if (mapList != null && mapList.size() > 0) {
  116 + getRoleList(mapList,levelCode,roleList,isChildren);
  117 + }
  118 + }
  119 +
  120 + } else {
  121 + for (Map<String, Object> map : list) {
  122 + if(map.get("levelCode").equals(levelCode)){
  123 + isChildren = true;
  124 + List mapList = (List) map.get("children");
  125 + if (mapList != null && mapList.size() > 0) {
  126 + getRoleList(mapList,levelCode,roleList,isChildren);
  127 + }
  128 + break;
  129 + } else {
  130 + List mapList = (List) map.get("children");
  131 + if (mapList != null && mapList.size() > 0) {
  132 + getRoleList(mapList,levelCode,roleList,isChildren);
  133 + }
  134 + }
  135 + }
  136 + }
  137 + } catch (Exception e) {
  138 + logger.error("error",e);
  139 + }
  140 + }
  141 +
  142 + public Map<String, Object> objectToMap(Object obj) throws Exception {
  143 + if(obj == null)
  144 + return null;
  145 +
  146 + Map<String, Object> map = new HashMap<>();
  147 +
  148 + BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
  149 + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
  150 + for (PropertyDescriptor property : propertyDescriptors) {
  151 + String key = property.getName();
  152 + if (key.compareToIgnoreCase("class") == 0) {
  153 + continue;
  154 + }
  155 + Method getter = property.getReadMethod();
  156 + Object value = getter!=null ? getter.invoke(obj) : null;
  157 + map.put(key, value);
  158 + }
  159 +
  160 + return map;
  161 + }
  162 +
  163 + private void ComparatorSysrole(List<HashMap> list) {
  164 + ComparatorSysrole comparator = new ComparatorSysrole();
  165 + Collections.sort(list, comparator);
  166 + for (HashMap map : list) {
  167 + List mapList = (List) map.get("children");
  168 + if (mapList != null && mapList.size() > 0) {
  169 + ComparatorSysrole(mapList);
  170 + }
  171 + }
  172 + }
  173 +
  174 + private class ComparatorSysrole implements Comparator {
  175 + public int compare(Object arg0, Object arg1) {
  176 + HashMap role0 = (HashMap) arg0;
  177 + HashMap role1 = (HashMap) arg1;
  178 +
  179 + // 首先比较父节点 相同比较 子 位序
  180 + Long role0Pid = (Long) (role0.get("upCode") == null ? (long) 0 : role0.get("upCode"));
  181 + Long role1Pid = (Long) (role1.get("upCode") == null ? (long) 0 : role1.get("upCode"));
  182 + int flag = role0Pid.compareTo(role1Pid);
  183 + if (flag == 0) {
  184 + return (Integer.valueOf(role0.get("roleIndex").toString())).compareTo(Integer.valueOf(role1.get(
  185 + "roleIndex").toString()));
  186 + } else {
  187 + return flag;
  188 + }
  189 + }
  190 + }
  191 +
  192 + @Override
  193 + public Map<String, Object> add(Role role) {
  194 + Map<String, Object> rs = new HashMap();
  195 + try{
  196 + SysUser user = SecurityUtils.getCurrentUser();
  197 + Iterator<Role> itRole = user.getRoles().iterator();
  198 + Role ro = new Role();
  199 + while(itRole.hasNext()){//判断是否有下一个
  200 + ro = itRole.next();
  201 + }
  202 + int id = roleRepository.roleMaxId()+1;
  203 + role.setUpCode(ro.getRoleCode());
  204 + role.setLevel(ro.getLevel()+1);
  205 + role.setRoleCode(id);
  206 + role.setId(id);
  207 + return super.save(role);
  208 + }catch (Exception e){
  209 + logger.error("", e);
  210 + rs.put("status", ResponseCode.ERROR);
  211 + rs.put("msg", e.getMessage());
  212 + }
  213 + return rs;
  214 + }
  215 +
  216 + @Override
40 217 public Map<String, Object> save(Role t) {
41 218 if (t.getId() != null) {
42 219 // 更新
... ... @@ -54,11 +231,11 @@ public class RoleServiceImpl extends BaseServiceImpl&lt;Role, Integer&gt; implements
54 231 }
55 232  
56 233 @Override
57   - public Map<String, Object> settRoleModules(Integer roleId, String mIds) {
  234 + public Map<String, Object> settRoleModules(Integer roleCode, String mIds) {
58 235  
59 236 Map<String, Object> map = new HashMap<>();
60 237 try {
61   - Role role = roleRepository.findOne(roleId);
  238 + Role role = roleRepository.findOne(roleCode);
62 239  
63 240 List<Integer> idList = new ArrayList<>();
64 241 String[] array = mIds.split(",");
... ...
src/main/java/com/bsth/service/sys/impl/SysUserServiceImpl.java
1 1 package com.bsth.service.sys.impl;
2 2  
  3 +import com.alibaba.fastjson.JSONArray;
3 4 import com.bsth.common.ResponseCode;
  5 +import com.bsth.entity.sys.Role;
4 6 import com.bsth.entity.sys.SysUser;
5 7 import com.bsth.repository.sys.SysUserRepository;
  8 +import com.bsth.security.util.SecurityUtils;
6 9 import com.bsth.service.impl.BaseServiceImpl;
  10 +import com.bsth.service.sys.RoleService;
7 11 import com.bsth.service.sys.SysUserService;
  12 +import com.google.gson.Gson;
  13 +import com.google.gson.reflect.TypeToken;
8 14 import org.slf4j.Logger;
9 15 import org.slf4j.LoggerFactory;
10 16 import org.springframework.beans.factory.annotation.Autowired;
11 17 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
12 18 import org.springframework.stereotype.Service;
13 19  
  20 +import java.util.ArrayList;
14 21 import java.util.HashMap;
  22 +import java.util.Iterator;
15 23 import java.util.List;
16 24 import java.util.Map;
17 25  
... ... @@ -21,6 +29,9 @@ public class SysUserServiceImpl extends BaseServiceImpl&lt;SysUser, Integer&gt; implem
21 29 @Autowired
22 30 SysUserRepository sysUserRepository;
23 31  
  32 + @Autowired
  33 + RoleService roleService;
  34 +
24 35 Logger logger = LoggerFactory.getLogger(this.getClass());
25 36  
26 37 @Override
... ... @@ -74,6 +85,45 @@ public class SysUserServiceImpl extends BaseServiceImpl&lt;SysUser, Integer&gt; implem
74 85  
75 86 @Override
76 87 public List<SysUser> findAll_distinct() {
77   - return sysUserRepository.findAll_distinct();
  88 + Map<String, Object> map = roleService.findSubordinate();
  89 + Object object = roleService.findSubordinate().get("list");
  90 + List<SysUser> rsList = new ArrayList<>();
  91 +
  92 + // 有权限查看的角色
  93 +// List<Role> roleList = JSONArray.parseArray(map.get("list").toString(), Role.class);
  94 +
  95 + try{
  96 + Gson gson = new Gson();
  97 + // 有权限查看的角色
  98 + List<Role> roleList = gson.fromJson(map.get("list").toString(), new TypeToken<List<Role>>(){}.getType());
  99 +
  100 + if(roleList.size() != 0 && !roleList.isEmpty()){
  101 + // 遍历有权限查看的角色
  102 + Map<Integer,Role> roleMap = new HashMap<>();
  103 + for (Role role: roleList) {
  104 + roleMap.put(role.getId(),role);
  105 + }
  106 +
  107 + List<SysUser> list = new ArrayList<>();
  108 + list = sysUserRepository.findAll_distinct();
  109 + for (SysUser sysUsers:list) {
  110 +
  111 + Iterator<Role> itUser = sysUsers.getRoles().iterator();
  112 + Role roleUser = new Role();
  113 + while(itUser.hasNext()){//判断是否有下一个
  114 + roleUser = itUser.next();
  115 + }
  116 + // 添加权限内的用户
  117 + if(roleMap.get(roleUser.getId()) != null){
  118 + rsList.add(sysUsers);
  119 + }
  120 + }
  121 + }
  122 + } catch (Exception e){
  123 + logger.error("error", e);
  124 + }
  125 +
  126 +
  127 + return rsList;
78 128 }
79 129 }
... ...
src/main/java/com/bsth/util/RoadCutDoubleName.java
... ... @@ -203,7 +203,7 @@ public class RoadCutDoubleName {
203 203 maxOne += 4;
204 204 maxTwo += 4;
205 205 d = maxTwo;
206   - roadName.add(theMainRoad + "(" + theFirstRoad + "-" + theSecondRoad + ")");
  206 + roadName.add(theMainRoad + "(" + theFirstRoad + "-" + theSecondRoad + ")");
207 207 }
208 208 // 将所有经纬度列表进行重复过滤
209 209 for (int i = 0; i < el.size() - 1; i++) {
... ...
src/main/resources/static/pages/base/line/editRoute.html
... ... @@ -82,7 +82,7 @@
82 82 </div>
83 83 <script type="text/javascript">
84 84  
85   -$('#edit_route_mobal').on('editRouteMobal.show', function(e,transGPS,editRoute,map,dra,ajaxd,fun){
  85 +$('#edit_route_mobal').on('editRouteMobal.show', function(e,transGPS,editRoute,map,dra,ajaxd,fun){
86 86 // 延迟加载显示mobal
87 87 setTimeout(function(){$('#edit_route_mobal').modal({show : true,backdrop: 'static', keyboard: false});},200);
88 88 // 获取表单元素
... ... @@ -197,7 +197,7 @@ $(&#39;#edit_route_mobal&#39;).on(&#39;editRouteMobal.show&#39;, function(e,transGPS,editRoute,m
197 197 // 原始坐标类型
198 198 params.dbType = 'b';
199 199 // 圆形半径
200   - params.radius = '100';
  200 + params.radius = '80';
201 201 // 限速
202 202 params.speedLimit = '60';
203 203 // 图形类型(r:圆形;p:多边形)
... ...
src/main/resources/static/pages/base/line/js/line-list-table.js
... ... @@ -201,7 +201,6 @@
201 201 }
202 202 // 异步请求获取表格数据
203 203 $.get('/line',params,function(result){
204   - debugger;
205 204 // 添加序号
206 205 result.content.page = page;
207 206 $.each(result.content, function(i, data) {
... ... @@ -339,51 +338,30 @@
339 338 layer.msg('请选中一条线路!');
340 339 return ;
341 340 }else {
342   - layer.open({
343   - title: "线路文件版本号",
344   - // skin:'layui-layer-rim',
345   - area:['450px', 'auto'],
346   -
347   - content: '<div class="col-sm-12">'
348   - +'<div class="input-group">'
349   - +'<span class="input-group-addon"> 线路文件版本号 :</span>'
350   - +'<input id="fileVersionsInput" type="text" class="form-control" placeholder="没有填写默认为2">'
351   - +'</div>'
352   - +'</div>',
353   - btn:['确定','取消'],
354   - btn1: function (index,layero) {
355   - var fileVersions = $('#fileVersionsInput').val();
356   - id = arrChk.data('id');
357   - lineName = arrChk.val();
358   - // 请求参数
359   - var params = {lineId:id, fileVersions:fileVersions};
360   - // 关闭弹出框
361   - layer.close(index);
362   - // 弹出正在加载层
363   - var index2 = layer.load(0);
364   - /** 生成线路行单 @pararm:<params:请求参数> */
365   - $post('/stationroute/usingSingle',params,function(data) {
366   - // 关闭弹出框
367   - layer.close(index2);
368   - if(data.status=='SUCCESS') {
369   - // 弹出添加成功提示消息
370   - layer.msg('生成线路【'+ lineName +'】线路文件成功!');
371   - }else if(data.status=='ERROR'){
372   - // 弹出添加成功提示消息
373   - layer.msg('生成线路【'+ lineName +'】线路文件失败!');
374   - }else if(data.status=='NOTDATA') {
375   - // 弹出添加成功提示消息
376   - layer.msg('系统无线路【'+ lineName +'】的站点与路段信息!');
377   - }else if(data.status=='NOLinePlayType') {
378   - // 弹出添加成功提示消息
379   - layer.msg('无法识别【'+ lineName +'】的线路规划类型,请设置为双向/环线!');
380   - }
381   - });
382   - },
383   - btn2:function (index,layero) {
384   - layer.close(index);
  341 + id = arrChk.data('id');
  342 + lineName = arrChk.val();
  343 + // 请求参数
  344 + var params = {lineId:id};
  345 + // 弹出正在加载层
  346 + var index2 = layer.load(0);
  347 + /** 生成线路行单 @pararm:<params:请求参数> */
  348 + $post('/stationroute/usingSingle',params,function(data) {
  349 + debugger;
  350 + // 关闭弹出框
  351 + layer.close(index2);
  352 + if(data.status=='SUCCESS') {
  353 + // 弹出添加成功提示消息
  354 + layer.msg('生成线路【'+ lineName +'】线路文件成功!');
  355 + }else if(data.status=='ERROR'){
  356 + // 弹出添加成功提示消息
  357 + layer.msg('生成线路【'+ lineName +'】线路文件失败!');
  358 + }else if(data.status=='NOTDATA') {
  359 + // 弹出添加成功提示消息
  360 + layer.msg('系统无线路【'+ lineName +'】的站点与路段信息!');
  361 + }else if(data.status=='NOLinePlayType') {
  362 + // 弹出添加成功提示消息
  363 + layer.msg('无法识别【'+ lineName +'】的线路规划类型,请设置为双向/环线!');
385 364 }
386   -
387 365 });
388 366 }
389 367 });
... ...
src/main/resources/static/pages/base/line/map.html
... ... @@ -111,6 +111,10 @@ $(function(){
111 111 var id = $.url().param('no');
112 112 // 方向 (0:上行;1:下行)默认上行
113 113 var direction = 0;
  114 + // 房防止页面session失效
  115 + setInterval(function () {
  116 + $get('/line/' + id ,null, function(result){});
  117 + },1000*60*120);
114 118 // 站点Map
115 119 var stationRouteMap = new Map();
116 120 // 路段Map
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
... ... @@ -90,7 +90,7 @@ window.WorldsBMap = function () {
90 90 // 初始化百度地图
91 91 mapBValue = new BMap.Map("bmap_basic" , {enableMapClick: false});
92 92 //中心点和缩放级别
93   - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng, CENTER_POINT.lat), 15);
  93 + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng, CENTER_POINT.lat), 14);
94 94 //启用地图拖拽事件,默认启用(可不写)
95 95 mapBValue.enableDragging();
96 96 //启用地图滚轮放大缩小
... ... @@ -470,7 +470,7 @@ window.WorldsBMap = function () {
470 470 }
471 471 // mapBValue.setCenter(polyline_center);
472 472 mapBValue.panTo(polyline_center);
473   - // mapBValue.setZoom(15);
  473 + // mapBValue.setZoom(14);
474 474 // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增)
475 475 // polyUpline01.disableMassClear();
476 476 }
... ...
src/main/resources/static/pages/permission/authorize_all/authorize.html
... ... @@ -395,7 +395,7 @@
395 395 r.createDateStr=moment(r.createDate).format('YYYY-MM-DD HH:ss');
396 396 r.codeUp=r.codeName.toUpperCase();
397 397 for(var j=0,u;u=users[j++];){
398   - if(u.roles.indexOf(r.id)!=-1){
  398 + if(u.roles[0].id == (r.id)){
399 399 r.count++;
400 400 role_users[r.id].push(u);
401 401 }
... ... @@ -459,21 +459,56 @@
459 459 //滚动条
460 460 $('.ct_page .uk-card .ct-card-body').perfectScrollbar({suppressScrollX: true});
461 461  
462   - //query all role
463   - $.get('/role/all', function (rs) {
464   - ep.emit('query_roles', rs);
  462 + //query Subordinate role
  463 + /*$.get('/role/findSubordinate', function (rs) {
  464 + if(rs.status == "SUCCESS"){
  465 + var roleList = rs.list;
  466 + ep.emit('query_roles', roleList);
  467 + if(roleList.length > 0 ){
  468 + //query all user
  469 + $.get('/user/all_distinct', function (rs) {
  470 + var rsList =[];
  471 + // 遍历有权限查看的角色
  472 + var roleMap = new Map();
  473 + $.each(roleList,function (i, role ){
  474 + roleMap.set(role.id,role);
  475 + });
  476 + for(var i=0,u;u=rs[i++];){
  477 +
  478 + // 添加权限内的用户
  479 + if(roleMap.get(u.roles[0].id) != null){
  480 + discard_field(u);
  481 + u.userNameUp=u.userName.toUpperCase();
  482 + u.lastLoginDateStr=moment(u.lastLoginDate).format('YYYY-MM-DD HH:ss');
  483 + rsList.push(u);
  484 + }
  485 +
  486 + }
  487 + ep.emit('query_users', rsList);
  488 + });
  489 + } else {
  490 + //您没有下级角色可管理,请添加角色,如果没有角色添加权限请联系超级管理员!
  491 + }
  492 +
  493 + }
  494 +
  495 + });*/
  496 +
  497 + //query Subordinate role
  498 + $.get('/role/findSubordinate', function (rs) {
  499 + if (rs.status == "SUCCESS") {
  500 + ep.emit('query_roles', rs.list);
  501 + }
465 502 });
466 503  
467   - //query all user
  504 + //query Subordinate user
468 505 $.get('/user/all_distinct', function (rs) {
469   - for(var i=0,u;u=rs[i++];){
470   - discard_field(u);
471   - u.userNameUp=u.userName.toUpperCase();
472   - u.lastLoginDateStr=moment(u.lastLoginDate).format('YYYY-MM-DD HH:ss');
473   - }
474 506 ep.emit('query_users', rs);
475 507 });
476 508  
  509 +
  510 +
  511 +
477 512 //query all modules
478 513 $.get('/module/all_distinct', function (rs) {
479 514 ep.emit('query_modules', rs);
... ... @@ -500,6 +535,7 @@
500 535 function render_role_list(list) {
501 536 var htmlStr = template('authorize-role-list-temp', {list: list});
502 537 $('ul.role-list').html(htmlStr);
  538 + debugger;
503 539 up_scroll();
504 540 }
505 541  
... ...
src/main/resources/static/pages/permission/authorize_all/role_auth.html
... ... @@ -2,10 +2,10 @@
2 2 <div id="role_authorize_wrap" style="height: 100%;">
3 3 <div class="top_title"></div>
4 4 <div class="uk-grid-small uk-child-width-expand" uk-grid style="height: calc(100% - 61px);">
5   - <div class="left_menu_list uk-width-2-5">
6   - <div class="save_icon" id="save_menus_btn" > 保存</div>
7   - <ul class="ztree" id="treeUlWrap"></ul>
8   - </div>
  5 + <!--<div class="left_menu_list uk-width-2-5">-->
  6 + <!--<div class="save_icon" id="save_menus_btn" > 保存</div>-->
  7 + <!--<ul class="ztree" id="treeUlWrap"></ul>-->
  8 + <!--</div>-->
9 9 <div class="data_auth_list" >
10 10 <div class="save_icon" id="save_company_data_btn" > 保存</div>
11 11 <h4 class="uk-heading-bullet" style="margin-top: 15px;">角色数据权限</h4>
... ...
src/main/resources/static/pages/permission/role/add.html
... ... @@ -117,10 +117,29 @@ $(function(){
117 117 //检查一下角色代码是否存在
118 118 $get('/role/all', {codeName_eq: params.codeName}, function(list){
119 119 if(!list || list.length == 0){
120   - $post('/role', params, function(res){
  120 + params.level = 2;
  121 + /*$post('/role/add', params, function(res){
121 122 layer.msg('添加角色成功.');
122 123 loadPage('list.html');
123   - });
  124 + });*/
  125 + $.ajax({
  126 + url: '/role/add',
  127 + type: 'POST',
  128 + traditional: true,
  129 + data: params,
  130 + success: function(rs){
  131 + if(!rs){
  132 + layer.msg('未知异常!');
  133 + }
  134 + if(rs.status=='SUCCESS'){
  135 + layer.msg('添加角色成功.');
  136 + loadPage('list.html');
  137 + }
  138 + else if(rs.status=='ERROR'){
  139 + layer.msg('添加失败[ ' + rs.msg + ']');
  140 + }
  141 + }
  142 + });
124 143 }
125 144 else
126 145 layer.alert('角色代码【' + params.codeName + '】已存在', {icon: 2, title: '提交被拒绝'});
... ...
src/main/resources/static/pages/permission/role/list.html
... ... @@ -85,7 +85,8 @@
85 85  
86 86 <script>
87 87 $(function(){
88   - $get('/role/all', null, function(list){
  88 + $get('/role/findSubordinate', null, function(rs){
  89 + var list = rs.list;
89 90 roleDateFormat(list);
90 91 var htmlStr = template('role_list_temp', {list: list});
91 92 $('#roleCards').html(htmlStr);
... ...
src/main/resources/static/pages/permission/user/add.html
... ... @@ -94,11 +94,20 @@
94 94 </div>
95 95 <script>
96 96 $(function(){
97   - $get('/role/all',null,function(result){
  97 + /*$get('/role/all',null,function(result){
98 98 $.each(result,function(i,obj){
99 99 $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
100 100 });
101   - });
  101 + });*/
  102 +
  103 + // 查询下级角色
  104 + $.get('/role/findSubordinate', function (rs) {
  105 + if(rs.status == "SUCCESS"){
  106 + $.each(rs.list,function(i,obj){
  107 + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
  108 + });
  109 + }
  110 + });
102 111  
103 112 var form = $('#user_add_form');
104 113 var error = $('.alert-danger', form);
... ...
src/main/resources/static/pages/permission/user/authorize.html
... ... @@ -390,7 +390,6 @@
390 390 companyData = cs;
391 391 lineArray=lines;
392 392 role_users = {};
393   - debugger
394 393 for(var i=0,r;r=roles[i++];){
395 394 r.count=0;
396 395 role_users[r.id]=[];
... ...
src/main/resources/static/pages/permission/user/edit.html
... ... @@ -107,14 +107,25 @@
107 107 $("#userName").attr('value',obj.userName);
108 108 $("#name").attr('value',obj.name);
109 109 $("#agencies").attr('value',obj.agencies);
110   - $get('/role/all',null,function(result){
  110 + /*$get('/role/all',null,function(result){
111 111 $.each(result,function(i,r){
112 112 $("#role").append("<option value='"+r.id+"'>"+r.roleName+"</option>");
113 113 });
114 114 $.each(obj.roles,function(i,obt){
115 115 $("#role option[value="+obt.id+"]").attr("selected",true);
116 116 });
117   - });
  117 + });*/
  118 + // 查询下级角色
  119 + $.get('/role/findSubordinate', function (rs) {
  120 + if(rs.status == "SUCCESS"){
  121 + $.each(rs.list,function(i,obj){
  122 + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
  123 + });
  124 + }
  125 + $.each(obj.roles,function(i,obt){
  126 + $("#role option[value="+obt.id+"]").attr("selected",true);
  127 + });
  128 + });
118 129 if(obj.enabled){
119 130 $("#enabled option[value=1]").attr("selected",true);
120 131 }else{
... ...
src/main/resources/static/pages/permission/user/list.html
... ... @@ -85,7 +85,8 @@
85 85 {{each list as obj i}}
86 86 <tr>
87 87 <td style="vertical-align: middle;">
88   - <input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">
  88 + <!--<input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">-->
  89 + {{++i}}
89 90 </td>
90 91 <td>
91 92 {{obj.userName}}
... ... @@ -111,11 +112,11 @@
111 112 <td>
112 113 {{obj.lastLoginDate}}
113 114 </td>
114   -
115   -
116 115 <td>
117   - <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}" data-pjax><i class="fa fa-edit"></i> 编辑</a>
118   - <!--<button type="button" class="btn btn-sm line_allot_btn" data-id="{{obj.id}}">线调线路分配</button>-->
  116 + {{if obj.isEdit == 0}}
  117 + <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}" data-pjax><i class="fa fa-edit"></i> 编辑</a>
  118 + <!--<button type="button" class="btn btn-sm line_allot_btn" data-id="{{obj.id}}">线调线路分配</button>-->
  119 + {{/if}}
119 120 </td>
120 121 </tr>
121 122 {{/each}}
... ... @@ -129,133 +130,148 @@
129 130 <script>
130 131 $(function(){
131 132 var page = 0, initPagination;
  133 + var user;
132 134 var icheckOptions = {
133 135 checkboxClass: 'icheckbox_flat-blue',
134 136 increaseArea: '20%'
135 137 };
136   -
137   - jsDoQuery(null,true);
138   -
139   - //重置
140   - $('tr.filter .filter-cancel').on('click', function(){
141   - $('tr.filter input, select').val('').change();
142   - jsDoQuery(null, true);
143   - });
144   -
145   - //提交
146   - $('tr.filter .filter-submit').on('click', function(){
147   - var cells = $('tr.filter')[0].cells
148   - ,params = {}
149   - ,name;
150   - $.each(cells, function(i, cell){
151   - var items = $('input,select', cell);
152   - for(var j = 0, item; item = items[j++];){
153   - name = $(item).attr('name');
154   - if(name){
155   - params[name] = $(item).val();
156   - }
157   - }
158   - });
159   - page = 0;
160   - jsDoQuery(params, true);
161   - });
162   -
163   - /*
164   - * 获取数据 p: 要提交的参数, pagination: 是否重新分页
165   - */
166   - function jsDoQuery(p, pagination){
167   - var params = {};
168   - if(p)
169   - params = p;
170   - //更新时间排序
171   - params['order'] = 'lastLoginDate';
172   - params['page'] = page;
173   - var i = layer.load(2);
174   - $get('/user' ,params, function(data){
175   - $.each(data.content, function(i, obj) {
176   - obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss");
  138 + $.get('/user/getCurrentUser', function(data) {
  139 + user = data;
  140 + });
  141 + setTimeout(function () {
  142 + jsDoQuery(null,true);
  143 +
  144 + //重置
  145 + $('tr.filter .filter-cancel').on('click', function(){
  146 + $('tr.filter input, select').val('').change();
  147 + jsDoQuery(null, true);
  148 + });
  149 +
  150 + //提交
  151 + $('tr.filter .filter-submit').on('click', function(){
  152 + var cells = $('tr.filter')[0].cells
  153 + ,params = {}
  154 + ,name;
  155 + $.each(cells, function(i, cell){
  156 + var items = $('input,select', cell);
  157 + for(var j = 0, item; item = items[j++];){
  158 + name = $(item).attr('name');
  159 + if(name){
  160 + params[name] = $(item).val();
  161 + }
  162 + }
  163 + });
  164 + page = 0;
  165 + jsDoQuery(params, true);
  166 + });
  167 +
  168 + /*
  169 + * 获取数据 p: 要提交的参数, pagination: 是否重新分页
  170 + */
  171 + function jsDoQuery(p, pagination){
  172 + var params = {};
  173 + if(p)
  174 + params = p;
  175 + //更新时间排序
  176 + params['order'] = 'lastLoginDate';
  177 + params['page'] = page;
  178 + params['roles[0].pic_ne'] = 1;
  179 + var i = layer.load(2);
  180 + $get('/user' ,params, function(data){
  181 + var list = data.content;
  182 + var errorList=[];
  183 + $.each(list, function(i, obj) {
  184 + if(obj.roles[0].level > user.roles[0].level){
  185 + obj.isEdit = 0;
  186 + } else{
  187 + obj.isEdit = 1;
  188 + }
  189 + obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss");
  190 + });
  191 +
  192 + var bodyHtm = template('user_list_temp', {list: list});
  193 +
  194 + $('#datatable_user tbody').html(bodyHtm)
  195 + .find('.icheck').iCheck(icheckOptions)
  196 + .on('ifChanged', iCheckChange);
  197 + if(pagination && list.length > 0){
  198 + //重新分页
  199 + initPagination = true;
  200 + showPagination(data);
  201 + }
  202 + layer.close(i);
  203 +
  204 + $('.line_allot_btn').on('click', openAllotWindow);
  205 + });
  206 + }
  207 +
  208 + function iCheckChange(){
  209 + var tr = $(this).parents('tr');
  210 + if(this.checked)
  211 + tr.addClass('row-active');
  212 + else
  213 + tr.removeClass('row-active');
  214 +
  215 + if($('#datatable_resource input.icheck:checked').length == 1)
  216 + $('#removeButton').removeAttr('disabled');
  217 + else
  218 + $('#removeButton').attr('disabled', 'disabled');
  219 + }
  220 +
  221 + function showPagination(data){
  222 + //分页
  223 + $('#pagination').jqPaginator({
  224 + totalPages: data.totalPages,
  225 + visiblePages: 6,
  226 + currentPage: page + 1,
  227 + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
  228 + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
  229 + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
  230 + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
  231 + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
  232 + onPageChange: function (num, type) {
  233 + if(initPagination){
  234 + initPagination = false;
  235 + return;
  236 + }
  237 +
  238 +
  239 + page = num - 1;
  240 + jsDoQuery(null, false);
  241 + }
  242 + });
  243 + }
  244 +
  245 + function openAllotWindow() {
  246 + var id = $(this).data('id');
  247 + $.get('/pages/permission/user/controlAllot.html', function (content) {
  248 + layer.open({
  249 + type: 1,
  250 + area: ['600px', '395px'],
  251 + content: content,
  252 + title: '线路调度权限分配',
  253 + shift: 5,
  254 + scrollbar: false,
  255 + success: function () {
  256 + $('#pageRealControlAllotWrap').trigger('init', id);
  257 + }
  258 + });
  259 + });
  260 + }
  261 +
  262 + //删除
  263 + $('#removeButton').on('click', function(){
  264 + if($(this).attr('disabled'))
  265 + return;
  266 +
  267 + var id = $('#datatable_resource input.icheck:checked').data('id');
  268 +
  269 + removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){
  270 + $('tr.filter .filter-submit').click();
177 271 });
178   - var bodyHtm = template('user_list_temp', {list: data.content});
179   -
180   - $('#datatable_user tbody').html(bodyHtm)
181   - .find('.icheck').iCheck(icheckOptions)
182   - .on('ifChanged', iCheckChange);
183   - if(pagination && data.content.length > 0){
184   - //重新分页
185   - initPagination = true;
186   - showPagination(data);
187   - }
188   - layer.close(i);
  272 + });
  273 + },1000);
189 274  
190   - $('.line_allot_btn').on('click', openAllotWindow);
191   - });
192   - }
193   -
194   - function iCheckChange(){
195   - var tr = $(this).parents('tr');
196   - if(this.checked)
197   - tr.addClass('row-active');
198   - else
199   - tr.removeClass('row-active');
200   -
201   - if($('#datatable_resource input.icheck:checked').length == 1)
202   - $('#removeButton').removeAttr('disabled');
203   - else
204   - $('#removeButton').attr('disabled', 'disabled');
205   - }
206   -
207   - function showPagination(data){
208   - //分页
209   - $('#pagination').jqPaginator({
210   - totalPages: data.totalPages,
211   - visiblePages: 6,
212   - currentPage: page + 1,
213   - first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
214   - prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
215   - next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
216   - last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
217   - page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
218   - onPageChange: function (num, type) {
219   - if(initPagination){
220   - initPagination = false;
221   - return;
222   - }
223   -
224   -
225   - page = num - 1;
226   - jsDoQuery(null, false);
227   - }
228   - });
229   - }
230   -
231   - function openAllotWindow() {
232   - var id = $(this).data('id');
233   - $.get('/pages/permission/user/controlAllot.html', function (content) {
234   - layer.open({
235   - type: 1,
236   - area: ['600px', '395px'],
237   - content: content,
238   - title: '线路调度权限分配',
239   - shift: 5,
240   - scrollbar: false,
241   - success: function () {
242   - $('#pageRealControlAllotWrap').trigger('init', id);
243   - }
244   - });
245   - });
246   - }
247   -
248   - //删除
249   - $('#removeButton').on('click', function(){
250   - if($(this).attr('disabled'))
251   - return;
252   -
253   - var id = $('#datatable_resource input.icheck:checked').data('id');
254   -
255   - removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){
256   - $('tr.filter .filter-submit').click();
257   - });
258   - });
259 275 });
260 276 //改变状态
261 277 function changeEnabled(id,enabled){
... ...