Commit f143d5472eefe583de0553b94acb17fee69324a6
Merge branch 'minhang' of 192.168.168.201:panzhaov5/bsth_control into
minhang # Conflicts: # src/main/resources/static/pages/forms/statement/waybill.html
Showing
22 changed files
with
1147 additions
and
294 deletions
src/main/java/com/bsth/common/Constants.java
src/main/java/com/bsth/controller/sys/CompanyAuthorityController.java
0 → 100644
| 1 | +package com.bsth.controller.sys; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSONArray; | |
| 4 | +import com.bsth.controller.BaseController; | |
| 5 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 6 | +import com.bsth.service.sys.CompanyAuthorityService; | |
| 7 | +import org.apache.commons.lang3.StringEscapeUtils; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Created by panzhao on 2016/11/22. | |
| 18 | + */ | |
| 19 | +@RestController | |
| 20 | +@RequestMapping("companyAuthority") | |
| 21 | +public class CompanyAuthorityController extends BaseController<CompanyAuthority, Integer>{ | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + CompanyAuthorityService companyAuthorityService; | |
| 25 | + | |
| 26 | + @RequestMapping(value = "save") | |
| 27 | + public Map<String, Object> save(@RequestParam Integer roleId, @RequestParam String authJsonStr){ | |
| 28 | + authJsonStr = StringEscapeUtils.unescapeHtml4(authJsonStr); | |
| 29 | + System.out.println(authJsonStr); | |
| 30 | + List<CompanyAuthority> list = JSONArray.parseArray(authJsonStr, CompanyAuthority.class); | |
| 31 | + return companyAuthorityService.save(roleId, list); | |
| 32 | + } | |
| 33 | +} | ... | ... |
src/main/java/com/bsth/controller/sys/UserController.java
| 1 | 1 | package com.bsth.controller.sys; |
| 2 | 2 | |
| 3 | -import java.util.HashMap; | |
| 4 | -import java.util.Map; | |
| 5 | - | |
| 6 | -import javax.servlet.http.HttpServletRequest; | |
| 7 | -import javax.servlet.http.HttpSession; | |
| 8 | - | |
| 3 | +import com.bsth.common.Constants; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.controller.BaseController; | |
| 6 | +import com.bsth.controller.sys.dto.CompanyData; | |
| 7 | +import com.bsth.controller.sys.util.RSAUtils; | |
| 8 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 9 | +import com.bsth.entity.sys.SysUser; | |
| 10 | +import com.bsth.security.util.SecurityUtils; | |
| 11 | +import com.bsth.service.sys.CompanyAuthorityService; | |
| 12 | +import com.bsth.service.sys.SysUserService; | |
| 13 | +import com.google.common.collect.ArrayListMultimap; | |
| 9 | 14 | import org.apache.commons.lang3.StringUtils; |
| 10 | 15 | import org.slf4j.Logger; |
| 11 | 16 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -18,13 +23,9 @@ import org.springframework.web.bind.annotation.RequestMethod; |
| 18 | 23 | import org.springframework.web.bind.annotation.RequestParam; |
| 19 | 24 | import org.springframework.web.bind.annotation.RestController; |
| 20 | 25 | |
| 21 | -import com.bsth.common.Constants; | |
| 22 | -import com.bsth.common.ResponseCode; | |
| 23 | -import com.bsth.controller.BaseController; | |
| 24 | -import com.bsth.controller.sys.util.RSAUtils; | |
| 25 | -import com.bsth.entity.sys.SysUser; | |
| 26 | -import com.bsth.security.util.SecurityUtils; | |
| 27 | -import com.bsth.service.sys.SysUserService; | |
| 26 | +import javax.servlet.http.HttpServletRequest; | |
| 27 | +import javax.servlet.http.HttpSession; | |
| 28 | +import java.util.*; | |
| 28 | 29 | |
| 29 | 30 | @RestController |
| 30 | 31 | @RequestMapping("user") |
| ... | ... | @@ -34,6 +35,9 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 34 | 35 | |
| 35 | 36 | @Autowired |
| 36 | 37 | SysUserService sysUserService; |
| 38 | + | |
| 39 | + @Autowired | |
| 40 | + CompanyAuthorityService companyAuthorityService; | |
| 37 | 41 | |
| 38 | 42 | @RequestMapping(value = "/login/jCryptionKey") |
| 39 | 43 | public Map<String, Object> jCryptionKey(HttpServletRequest request){ |
| ... | ... | @@ -97,7 +101,11 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 97 | 101 | SecurityUtils.login(user, request); |
| 98 | 102 | //session里写入用户名,webSocket连接时标识身份用 |
| 99 | 103 | session.setAttribute(Constants.SESSION_USERNAME, user.getUserName()); |
| 100 | - | |
| 104 | + | |
| 105 | + //获取公司权限数据 | |
| 106 | + List<CompanyAuthority> cmyAuths=companyAuthorityService.findByUser(user); | |
| 107 | + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths); | |
| 108 | + | |
| 101 | 109 | captchaMap.remove(userName); |
| 102 | 110 | rs.put("status", ResponseCode.SUCCESS); |
| 103 | 111 | } catch (Exception e) { |
| ... | ... | @@ -106,6 +114,43 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 106 | 114 | } |
| 107 | 115 | return rs; |
| 108 | 116 | } |
| 117 | + | |
| 118 | + /** | |
| 119 | + * 返回当前用户的公司权限数据,用于构建页面级联下拉框 | |
| 120 | + * @return | |
| 121 | + */ | |
| 122 | + @RequestMapping("companyData") | |
| 123 | + public List<CompanyData> companyData(HttpServletRequest request){ | |
| 124 | + List<CompanyData> rs = new ArrayList<>(); | |
| 125 | + CompanyData companyData; | |
| 126 | + | |
| 127 | + ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create(); | |
| 128 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 129 | + | |
| 130 | + for(CompanyAuthority cAuth : cmyAuths){ | |
| 131 | + map.put(cAuth.getCompanyCode()+"_"+cAuth.getCompanyName(), cAuth); | |
| 132 | + } | |
| 133 | + | |
| 134 | + Set<String> keys = map.keySet(); | |
| 135 | + String[] temps; | |
| 136 | + for(String k : keys){ | |
| 137 | + temps = k.split("_"); | |
| 138 | + | |
| 139 | + companyData = new CompanyData(); | |
| 140 | + companyData.setCompanyCode(temps[0]); | |
| 141 | + companyData.setCompanyName(temps[1]); | |
| 142 | + companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>()); | |
| 143 | + | |
| 144 | + cmyAuths = map.get(k); | |
| 145 | + for(CompanyAuthority c : cmyAuths){ | |
| 146 | + companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName())); | |
| 147 | + } | |
| 148 | + | |
| 149 | + rs.add(companyData); | |
| 150 | + } | |
| 151 | + | |
| 152 | + return rs; | |
| 153 | + } | |
| 109 | 154 | |
| 110 | 155 | @RequestMapping(value = "/login/captchaStatus") |
| 111 | 156 | public int captchaStatus(String userName){ |
| ... | ... | @@ -162,7 +207,7 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 162 | 207 | * @Description: TODO(修改密码) |
| 163 | 208 | * @param oldPWD |
| 164 | 209 | * 原始密码 |
| 165 | - * @param newwPWD | |
| 210 | + * @param newPWD | |
| 166 | 211 | * 新密码 |
| 167 | 212 | * @param cnewPWD |
| 168 | 213 | * 确认新密码 | ... | ... |
src/main/java/com/bsth/controller/sys/dto/CompanyData.java
0 → 100644
| 1 | +package com.bsth.controller.sys.dto; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by panzhao on 2016/11/22. | |
| 7 | + */ | |
| 8 | +public class CompanyData { | |
| 9 | + | |
| 10 | + private String companyCode; | |
| 11 | + | |
| 12 | + private String companyName; | |
| 13 | + | |
| 14 | + private List<ChildrenCompany> children; | |
| 15 | + | |
| 16 | + public String getCompanyCode() { | |
| 17 | + return companyCode; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setCompanyCode(String companyCode) { | |
| 21 | + this.companyCode = companyCode; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getCompanyName() { | |
| 25 | + return companyName; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setCompanyName(String companyName) { | |
| 29 | + this.companyName = companyName; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public List<ChildrenCompany> getChildren() { | |
| 33 | + return children; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setChildren(List<ChildrenCompany> children) { | |
| 37 | + this.children = children; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public static class ChildrenCompany { | |
| 41 | + private String code; | |
| 42 | + | |
| 43 | + private String name; | |
| 44 | + | |
| 45 | + public ChildrenCompany(String code, String name){ | |
| 46 | + this.code = code; | |
| 47 | + this.name = name; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public String getName() { | |
| 51 | + return name; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public void setName(String name) { | |
| 55 | + this.name = name; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public String getCode() { | |
| 59 | + return code; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public void setCode(String code) { | |
| 63 | + this.code = code; | |
| 64 | + } | |
| 65 | + } | |
| 66 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
| 1 | 1 | package com.bsth.data.schedule.thread; |
| 2 | 2 | |
| 3 | -import java.util.LinkedList; | |
| 4 | - | |
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | 3 | import com.bsth.data.schedule.DayOfSchedule; |
| 9 | 4 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 10 | 5 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.orm.jpa.JpaObjectRetrievalFailureException; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import javax.persistence.EntityNotFoundException; | |
| 13 | +import java.util.LinkedList; | |
| 11 | 14 | |
| 12 | 15 | /** |
| 13 | - * | |
| 14 | - * @ClassName: SchedulePstThread | |
| 15 | - * @Description: TODO(班次异步持久化) | |
| 16 | - * @author PanZhao | |
| 17 | - * @date 2016年8月24日 上午1:47:05 | |
| 18 | - * | |
| 16 | + * @author PanZhao | |
| 17 | + * @ClassName: SchedulePstThread | |
| 18 | + * @Description: TODO(班次异步持久化) | |
| 19 | + * @date 2016年8月24日 上午1:47:05 | |
| 19 | 20 | */ |
| 20 | 21 | @Component |
| 21 | -public class SchedulePstThread extends Thread{ | |
| 22 | - | |
| 23 | - @Autowired | |
| 24 | - ScheduleRealInfoRepository scheduleRepository; | |
| 25 | - | |
| 26 | - @Override | |
| 27 | - public void run() { | |
| 28 | - LinkedList<ScheduleRealInfo> list = DayOfSchedule.pstBuffer; | |
| 29 | - | |
| 30 | - ScheduleRealInfo schedule; | |
| 31 | - for (int i = 0; i < 1000; i++) { | |
| 32 | - schedule = list.poll(); | |
| 33 | - if (null == schedule) | |
| 34 | - break; | |
| 35 | - | |
| 36 | - scheduleRepository.save(schedule); | |
| 37 | - } | |
| 38 | - } | |
| 22 | +public class SchedulePstThread extends Thread { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + ScheduleRealInfoRepository scheduleRepository; | |
| 26 | + | |
| 27 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + public void run() { | |
| 31 | + | |
| 32 | + LinkedList<ScheduleRealInfo> list = DayOfSchedule.pstBuffer; | |
| 33 | + | |
| 34 | + ScheduleRealInfo schedule; | |
| 35 | + for (int i = 0; i < 1000; i++) { | |
| 36 | + schedule = list.poll(); | |
| 37 | + if (null == schedule) | |
| 38 | + break; | |
| 39 | + | |
| 40 | + try { | |
| 41 | + scheduleRepository.save(schedule); | |
| 42 | + } | |
| 43 | + catch (JpaObjectRetrievalFailureException e1){ | |
| 44 | + logger.error("JpaObjectRetrievalFailureException error.... 可忽略"); | |
| 45 | + } | |
| 46 | + catch(EntityNotFoundException e2){ | |
| 47 | + logger.error("EntityNotFoundException error.... 可忽略"); | |
| 48 | + } | |
| 49 | + catch (Exception e) { | |
| 50 | + logger.error("", e); | |
| 51 | + } | |
| 52 | + } | |
| 53 | + } | |
| 39 | 54 | } | ... | ... |
src/main/java/com/bsth/entity/sys/CompanyAuthority.java
0 → 100644
| 1 | +package com.bsth.entity.sys; | |
| 2 | + | |
| 3 | +import javax.persistence.*; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by panzhao on 2016/11/22. | |
| 7 | + */ | |
| 8 | +@Entity | |
| 9 | +@Table(name = "bsth_c_sys_company_auth") | |
| 10 | +public class CompanyAuthority { | |
| 11 | + | |
| 12 | + @Id | |
| 13 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| 14 | + private Integer id; | |
| 15 | + | |
| 16 | + /** 公司代码 */ | |
| 17 | + private String companyCode; | |
| 18 | + | |
| 19 | + /** 公司名称 */ | |
| 20 | + private String companyName; | |
| 21 | + | |
| 22 | + /** 分公司代码 */ | |
| 23 | + private String subCompanyCode; | |
| 24 | + | |
| 25 | + /** 分公司代码 */ | |
| 26 | + private String subCompanyName; | |
| 27 | + | |
| 28 | + private Integer roleId; | |
| 29 | + | |
| 30 | + public String getSubCompanyName() { | |
| 31 | + return subCompanyName; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setSubCompanyName(String subCompanyName) { | |
| 35 | + this.subCompanyName = subCompanyName; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getSubCompanyCode() { | |
| 39 | + return subCompanyCode; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setSubCompanyCode(String subCompanyCode) { | |
| 43 | + this.subCompanyCode = subCompanyCode; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public String getCompanyName() { | |
| 47 | + return companyName; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setCompanyName(String companyName) { | |
| 51 | + this.companyName = companyName; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public String getCompanyCode() { | |
| 55 | + return companyCode; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void setCompanyCode(String companyCode) { | |
| 59 | + this.companyCode = companyCode; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public Integer getId() { | |
| 63 | + return id; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setId(Integer id) { | |
| 67 | + this.id = id; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public Integer getRoleId() { | |
| 71 | + return roleId; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void setRoleId(Integer roleId) { | |
| 75 | + this.roleId = roleId; | |
| 76 | + } | |
| 77 | +} | ... | ... |
src/main/java/com/bsth/repository/sys/CompanyAuthorityRepository.java
0 → 100644
| 1 | +package com.bsth.repository.sys; | |
| 2 | + | |
| 3 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 4 | +import com.bsth.repository.BaseRepository; | |
| 5 | +import org.springframework.data.jpa.repository.Modifying; | |
| 6 | +import org.springframework.data.jpa.repository.Query; | |
| 7 | +import org.springframework.stereotype.Repository; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Created by panzhao on 2016/11/22. | |
| 13 | + */ | |
| 14 | +@Repository | |
| 15 | +public interface CompanyAuthorityRepository extends BaseRepository<CompanyAuthority, Integer>{ | |
| 16 | + | |
| 17 | + @Modifying | |
| 18 | + @Query(value="DELETE FROM CompanyAuthority WHERE roleId = ?1") | |
| 19 | + void deleteByRoleId(Integer roleId); | |
| 20 | + | |
| 21 | + @Query(value = "select ca from CompanyAuthority ca where ca.roleId in ?1") | |
| 22 | + List<CompanyAuthority> findByRoles(List<Integer> idx); | |
| 23 | +} | ... | ... |
src/main/java/com/bsth/repository/sys/ModuleRepository.java
| 1 | 1 | package com.bsth.repository.sys; |
| 2 | 2 | |
| 3 | -import java.util.List; | |
| 4 | -import java.util.Set; | |
| 5 | - | |
| 3 | +import com.bsth.entity.sys.Module; | |
| 4 | +import com.bsth.repository.BaseRepository; | |
| 6 | 5 | import org.springframework.data.jpa.domain.Specification; |
| 7 | -import org.springframework.data.jpa.repository.EntityGraph; | |
| 8 | 6 | import org.springframework.data.jpa.repository.Query; |
| 9 | 7 | import org.springframework.stereotype.Repository; |
| 10 | 8 | |
| 11 | -import com.bsth.entity.sys.Module; | |
| 12 | -import com.bsth.repository.BaseRepository; | |
| 9 | +import java.util.List; | |
| 10 | +import java.util.Set; | |
| 13 | 11 | |
| 14 | 12 | @Repository |
| 15 | -public interface ModuleRepository extends BaseRepository<Module, Integer>{ | |
| 16 | - | |
| 17 | - @Query("select m from Module m where m.groupType in ?1") | |
| 18 | - List<Module> findByGroupType(String[] groupType); | |
| 19 | - | |
| 20 | - List<Module> findByPId(Integer pId); | |
| 21 | - | |
| 22 | - @Query("select m from Module m where m.id in ?1") | |
| 23 | - Set<Module> findByIds(List<Integer> ids); | |
| 24 | - | |
| 25 | - @Override | |
| 26 | - List<Module> findAll(Specification<Module> spec); | |
| 13 | +public interface ModuleRepository extends BaseRepository<Module, Integer> { | |
| 14 | + | |
| 15 | + @Query("select m from Module m where m.groupType in ?1") | |
| 16 | + List<Module> findByGroupType(String[] groupType); | |
| 17 | + | |
| 18 | + List<Module> findByPId(Integer pId); | |
| 19 | + | |
| 20 | + @Query("select m from Module m where m.id in ?1") | |
| 21 | + Set<Module> findByIds(List<Integer> ids); | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + List<Module> findAll(Specification<Module> spec); | |
| 25 | + | |
| 27 | 26 | } | ... | ... |
src/main/java/com/bsth/service/sys/CompanyAuthorityService.java
0 → 100644
| 1 | +package com.bsth.service.sys; | |
| 2 | + | |
| 3 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 4 | +import com.bsth.entity.sys.SysUser; | |
| 5 | +import com.bsth.service.BaseService; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Created by panzhao on 2016/11/22. | |
| 12 | + */ | |
| 13 | +public interface CompanyAuthorityService extends BaseService<CompanyAuthority, Integer> { | |
| 14 | + Map<String,Object> save(Integer roleId, List<CompanyAuthority> list); | |
| 15 | + | |
| 16 | + List<CompanyAuthority> findByUser(SysUser user); | |
| 17 | +} | ... | ... |
src/main/java/com/bsth/service/sys/impl/CompanyAuthorityServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.sys.impl; | |
| 2 | + | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 4 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 5 | +import com.bsth.entity.sys.Role; | |
| 6 | +import com.bsth.entity.sys.SysUser; | |
| 7 | +import com.bsth.repository.sys.CompanyAuthorityRepository; | |
| 8 | +import com.bsth.service.impl.BaseServiceImpl; | |
| 9 | +import com.bsth.service.sys.CompanyAuthorityService; | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.stereotype.Service; | |
| 14 | +import org.springframework.transaction.annotation.Transactional; | |
| 15 | + | |
| 16 | +import java.util.*; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * Created by panzhao on 2016/11/22. | |
| 20 | + */ | |
| 21 | +@Service | |
| 22 | +public class CompanyAuthorityServiceImpl extends BaseServiceImpl<CompanyAuthority, Integer> implements CompanyAuthorityService { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + CompanyAuthorityRepository companyAuthorityRepository; | |
| 26 | + | |
| 27 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 28 | + | |
| 29 | + @Transactional | |
| 30 | + @Override | |
| 31 | + public Map<String, Object> save(Integer roleId, List<CompanyAuthority> list) { | |
| 32 | + Map<String, Object> rs = new HashMap(); | |
| 33 | + | |
| 34 | + try { | |
| 35 | + for(CompanyAuthority cauth : list){ | |
| 36 | + cauth.setRoleId(roleId); | |
| 37 | + } | |
| 38 | + | |
| 39 | + //删除原数据 | |
| 40 | + companyAuthorityRepository.deleteByRoleId(roleId); | |
| 41 | + | |
| 42 | + //重新写入数据 | |
| 43 | + companyAuthorityRepository.save(list); | |
| 44 | + | |
| 45 | + rs.put("status", ResponseCode.SUCCESS); | |
| 46 | + } catch (Exception e) { | |
| 47 | + logger.error("", e); | |
| 48 | + rs.put("status", ResponseCode.ERROR); | |
| 49 | + } | |
| 50 | + | |
| 51 | + return rs; | |
| 52 | + } | |
| 53 | + | |
| 54 | + @Override | |
| 55 | + public List<CompanyAuthority> findByUser(SysUser user) { | |
| 56 | + Set<Role> roles = user.getRoles(); | |
| 57 | + if(roles == null || roles.size() == 0) | |
| 58 | + return null; | |
| 59 | + | |
| 60 | + List<Integer> idx = new ArrayList<>(); | |
| 61 | + for(Role r : roles) | |
| 62 | + idx.add(r.getId()); | |
| 63 | + | |
| 64 | + List<CompanyAuthority> cAuths = companyAuthorityRepository.findByRoles(idx); | |
| 65 | + return cAuths; | |
| 66 | + } | |
| 67 | +} | ... | ... |
src/main/java/com/bsth/service/sys/impl/ModuleServiceImpl.java
| 1 | 1 | package com.bsth.service.sys.impl; |
| 2 | 2 | |
| 3 | -import java.util.ArrayList; | |
| 4 | -import java.util.HashMap; | |
| 5 | -import java.util.HashSet; | |
| 6 | -import java.util.List; | |
| 7 | -import java.util.Map; | |
| 8 | -import java.util.Set; | |
| 9 | - | |
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | -import org.springframework.data.domain.Sort; | |
| 12 | -import org.springframework.data.domain.Sort.Direction; | |
| 13 | -import org.springframework.stereotype.Service; | |
| 14 | - | |
| 15 | 3 | import com.bsth.common.ResponseCode; |
| 16 | 4 | import com.bsth.entity.sys.Module; |
| 17 | 5 | import com.bsth.entity.sys.Role; |
| ... | ... | @@ -20,12 +8,23 @@ import com.bsth.repository.sys.ModuleRepository; |
| 20 | 8 | import com.bsth.security.util.SecurityUtils; |
| 21 | 9 | import com.bsth.service.impl.BaseServiceImpl; |
| 22 | 10 | import com.bsth.service.sys.ModuleService; |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 13 | +import org.springframework.jdbc.core.RowMapper; | |
| 14 | +import org.springframework.stereotype.Service; | |
| 15 | + | |
| 16 | +import java.sql.ResultSet; | |
| 17 | +import java.sql.SQLException; | |
| 18 | +import java.util.*; | |
| 23 | 19 | |
| 24 | 20 | @Service |
| 25 | 21 | public class ModuleServiceImpl extends BaseServiceImpl<Module, Integer> implements ModuleService{ |
| 26 | 22 | |
| 27 | 23 | @Autowired |
| 28 | 24 | ModuleRepository moduleRepository; |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + JdbcTemplate jdbcTemplate; | |
| 29 | 28 | |
| 30 | 29 | @Override |
| 31 | 30 | public List<Module> findByGroupType(String group) { |
| ... | ... | @@ -62,26 +61,38 @@ public class ModuleServiceImpl extends BaseServiceImpl<Module, Integer> implemen |
| 62 | 61 | SysUser user = SecurityUtils.getCurrentUser(); |
| 63 | 62 | Set<Role> roles = user.getRoles(); |
| 64 | 63 | |
| 65 | - List<Module> all = (List<Module>) moduleRepository.findAll(new Sort(Direction.ASC, "id")) | |
| 66 | - ,results = new ArrayList<>(); | |
| 67 | - | |
| 64 | + String inCond = ""; | |
| 65 | + for(Role r : roles) | |
| 66 | + inCond += ("," + r.getId()); | |
| 67 | + | |
| 68 | + inCond = "(" + inCond.substring(1) + ")"; | |
| 69 | + | |
| 70 | + String sql = "select ID,CREATE_DATE,`ENABLE`,GROUP_TYPE,ICON,MAPP_SYMBOL,NAME,P_ID,PATH,UPDATE_DATE,CONTAINER from bsth_c_sys_module m where id in (select modules from bsth_c_sys_role_modules where roles in "+inCond+") or group_type != 3"; | |
| 71 | + List<Module> all = jdbcTemplate.query(sql, new ModuleRowMapper()) | |
| 72 | + ,rs = new ArrayList<>(); | |
| 73 | + | |
| 68 | 74 | Map<Integer, Module> map = new HashMap<>(); |
| 69 | 75 | for(Module m : all){ |
| 70 | 76 | map.put(m.getId(), m); |
| 71 | - for(Role r : roles){ | |
| 72 | - if(m.getRoles().contains(r)) | |
| 73 | - results.add(m); | |
| 74 | - } | |
| 77 | + if(m.getGroupType().equals("3")) | |
| 78 | + rs.add(m); | |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | 81 | //上层目录和组节点 |
| 78 | 82 | Set<Module> pSet = new HashSet<>(); |
| 79 | - for(Module m : results){ | |
| 83 | + for(Module m : rs){ | |
| 80 | 84 | searchParentNode(m, map, pSet); |
| 81 | 85 | } |
| 82 | - results.addAll(pSet); | |
| 83 | - | |
| 84 | - return results; | |
| 86 | + rs.addAll(pSet); | |
| 87 | + | |
| 88 | + //排序 | |
| 89 | + Collections.sort(rs, new Comparator<Module>() { | |
| 90 | + @Override | |
| 91 | + public int compare(Module o1, Module o2) { | |
| 92 | + return o1.getId() - o2.getId(); | |
| 93 | + } | |
| 94 | + }); | |
| 95 | + return rs; | |
| 85 | 96 | } |
| 86 | 97 | |
| 87 | 98 | /** |
| ... | ... | @@ -105,4 +116,24 @@ public class ModuleServiceImpl extends BaseServiceImpl<Module, Integer> implemen |
| 105 | 116 | searchParentNode(pModule, idMap, pSet); |
| 106 | 117 | } |
| 107 | 118 | } |
| 119 | + | |
| 120 | + public class ModuleRowMapper implements RowMapper<Module>{ | |
| 121 | + | |
| 122 | + @Override | |
| 123 | + public Module mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 124 | + Module module = new Module(); | |
| 125 | + module.setId(rs.getInt("ID")); | |
| 126 | + module.setCreateDate(rs.getDate("CREATE_DATE")); | |
| 127 | + module.setEnable(rs.getBoolean("ENABLE")); | |
| 128 | + module.setGroupType(rs.getString("GROUP_TYPE")); | |
| 129 | + module.setIcon(rs.getString("ICON")); | |
| 130 | + module.setMappSymbol(rs.getString("MAPP_SYMBOL")); | |
| 131 | + module.setName(rs.getString("NAME")); | |
| 132 | + module.setpId(rs.getInt("P_ID")); | |
| 133 | + module.setPath(rs.getString("PATH")); | |
| 134 | + module.setUpdateDate(rs.getDate("UPDATE_DATE")); | |
| 135 | + module.setContainer(rs.getString("CONTAINER")); | |
| 136 | + return module; | |
| 137 | + } | |
| 138 | + } | |
| 108 | 139 | } | ... | ... |
src/main/resources/static/pages/forms/statement/waybill.html
| ... | ... | @@ -21,49 +21,49 @@ |
| 21 | 21 | <h1>行车路单</h1> |
| 22 | 22 | </div> |
| 23 | 23 | </div> |
| 24 | - | |
| 25 | -<div class="row"> | |
| 26 | - <div class="col-md-12"> | |
| 27 | - <div class="portlet light porttlet-fit bordered"> | |
| 28 | - <div class="portlet-title"> | |
| 29 | - <form class="form-inline" action=""> | |
| 30 | - <div style="display: inline-block;"> | |
| 24 | + | |
| 25 | +<div class="row"> | |
| 26 | + <div class="col-md-12"> | |
| 27 | + <div class="portlet light porttlet-fit bordered"> | |
| 28 | + <div class="portlet-title"> | |
| 29 | + <form class="form-inline" action=""> | |
| 30 | + <div style="display: inline-block;"> | |
| 31 | 31 | <span class="item-label" style="width: 80px;">线路: </span> |
| 32 | - <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 33 | - </div> | |
| 34 | - <div style="display: inline-block;margin-left: 15px;"> | |
| 35 | - <span class="item-label" style="width: 80px;">时间: </span> | |
| 36 | - <input class="form-control" type="text" id="date" style="width: 180px;"/> | |
| 37 | - </div> | |
| 38 | - <div class="form-group" style="display: inline-block;margin-left: 15px;"> | |
| 39 | - <input class="btn btn-default" type="button" id="query" value="查询"/> | |
| 40 | - <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 41 | - <input class="btn btn-default" type="button" id="print" value="打印"/> | |
| 42 | - <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> | |
| 43 | - </div> | |
| 44 | - </form> | |
| 45 | - </div> | |
| 46 | - <div class="portlet-body"> | |
| 47 | - <div class="row"> | |
| 48 | - <div class="col-md-3"> | |
| 49 | - <div class="" style="margin-top: 10px;overflow:auto;height: 860px"> | |
| 50 | - <table class="table table-bordered table-hover table-checkable pre-scrollable" id="info"> | |
| 51 | - <thead> | |
| 52 | - <tr class="hidden"> | |
| 53 | - <th>人员</th> | |
| 54 | - <th>自编号</th> | |
| 55 | - <th>路牌</th> | |
| 56 | - </tr> | |
| 57 | - </thead> | |
| 58 | - <tbody> | |
| 59 | - | |
| 60 | - </tbody> | |
| 61 | - </table> | |
| 62 | - </div> | |
| 63 | - </div> | |
| 64 | - <div class="col-md-9" id="printArea"> | |
| 65 | - <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | |
| 66 | - <table class="table table-bordered table-checkable" id="forms"> | |
| 32 | + <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 33 | + </div> | |
| 34 | + <div style="display: inline-block;margin-left: 15px;"> | |
| 35 | + <span class="item-label" style="width: 80px;">时间: </span> | |
| 36 | + <input class="form-control" type="text" id="date" style="width: 180px;"/> | |
| 37 | + </div> | |
| 38 | + <div class="form-group" style="display: inline-block;margin-left: 15px;"> | |
| 39 | + <input class="btn btn-default" type="button" id="query" value="查询"/> | |
| 40 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 41 | + <input class="btn btn-default" type="button" id="print" value="打印"/> | |
| 42 | + <input class="btn btn-default" type="button" id="exportMore" value="批量导出"/> | |
| 43 | + </div> | |
| 44 | + </form> | |
| 45 | + </div> | |
| 46 | + <div class="portlet-body"> | |
| 47 | + <div class="row"> | |
| 48 | + <div class="col-md-3"> | |
| 49 | + <div class="" style="margin-top: 10px;overflow:auto;height: 860px"> | |
| 50 | + <table class="table table-bordered table-hover table-checkable pre-scrollable" id="info"> | |
| 51 | + <thead> | |
| 52 | + <tr class="hidden"> | |
| 53 | + <th>人员</th> | |
| 54 | + <th>自编号</th> | |
| 55 | + <th>路牌</th> | |
| 56 | + </tr> | |
| 57 | + </thead> | |
| 58 | + <tbody> | |
| 59 | + | |
| 60 | + </tbody> | |
| 61 | + </table> | |
| 62 | + </div> | |
| 63 | + </div> | |
| 64 | + <div class="col-md-9" id="printArea"> | |
| 65 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | |
| 66 | + <table class="table table-bordered table-checkable" id="forms"> | |
| 67 | 67 | <tbody class="ludan_1"> |
| 68 | 68 | |
| 69 | 69 | </tbody> |
| ... | ... | @@ -75,25 +75,25 @@ |
| 75 | 75 | </tbody> |
| 76 | 76 | <tbody class="ludan_4"> |
| 77 | 77 | |
| 78 | - </tbody> | |
| 79 | - </table> | |
| 80 | - </div> | |
| 81 | - </div> | |
| 82 | - </div> | |
| 83 | - </div> | |
| 84 | - </div> | |
| 85 | - </div> | |
| 86 | -</div> | |
| 87 | - | |
| 88 | -<script> | |
| 89 | - $(function(){ | |
| 90 | - // 关闭左侧栏 | |
| 91 | - if (!$('body').hasClass('page-sidebar-closed')) | |
| 78 | + </tbody> | |
| 79 | + </table> | |
| 80 | + </div> | |
| 81 | + </div> | |
| 82 | + </div> | |
| 83 | + </div> | |
| 84 | + </div> | |
| 85 | + </div> | |
| 86 | +</div> | |
| 87 | + | |
| 88 | +<script> | |
| 89 | + $(function(){ | |
| 90 | + // 关闭左侧栏 | |
| 91 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 92 | 92 | $('.menu-toggler.sidebar-toggler').click(); |
| 93 | - | |
| 94 | - $("#date").datetimepicker({ | |
| 95 | - format : 'YYYY-MM-DD', | |
| 96 | - locale : 'zh-cn' | |
| 93 | + | |
| 94 | + $("#date").datetimepicker({ | |
| 95 | + format : 'YYYY-MM-DD', | |
| 96 | + locale : 'zh-cn' | |
| 97 | 97 | }); |
| 98 | 98 | |
| 99 | 99 | $.get('/basic/lineCode2Name',function(result){ |
| ... | ... | @@ -146,28 +146,29 @@ |
| 146 | 146 | } |
| 147 | 147 | }); |
| 148 | 148 | */ |
| 149 | - var date = ''; | |
| 150 | - $("#query").on("click",function(){ | |
| 151 | - var line = $("#line").val(); | |
| 149 | + | |
| 150 | + var date = ''; | |
| 151 | + $("#query").on("click",function(){ | |
| 152 | + var line = $("#line").val(); | |
| 152 | 153 | date = $("#date").val(); |
| 153 | - $(".hidden").removeClass("hidden"); | |
| 154 | - $get('/realSchedule/queryUserInfo',{line:line,date:date},function(result){ | |
| 155 | - // 把数据填充到模版中 | |
| 156 | - var tbodyHtml = template('list_info',{list:result}); | |
| 157 | - // 把渲染好的模版html文本追加到表格中 | |
| 158 | - $('#info tbody').html(tbodyHtml); | |
| 159 | - }); | |
| 154 | + $(".hidden").removeClass("hidden"); | |
| 155 | + $get('/realSchedule/queryUserInfo',{line:line,date:date},function(result){ | |
| 156 | + // 把数据填充到模版中 | |
| 157 | + var tbodyHtml = template('list_info',{list:result}); | |
| 158 | + // 把渲染好的模版html文本追加到表格中 | |
| 159 | + $('#info tbody').html(tbodyHtml); | |
| 160 | + }); | |
| 160 | 161 | }); |
| 161 | 162 | |
| 162 | 163 | var params = new Array(); |
| 163 | - var jName = ''; | |
| 164 | + var jName = ''; | |
| 164 | 165 | $("#info tbody").on("click","tr",function(){ |
| 165 | 166 | if($(this).children().size() < 2){ |
| 166 | 167 | return; |
| 167 | - } | |
| 168 | - | |
| 169 | - $(this).children().each(function(index){ | |
| 170 | - params[index] = $(this).text(); | |
| 168 | + } | |
| 169 | + | |
| 170 | + $(this).children().each(function(index){ | |
| 171 | + params[index] = $(this).text(); | |
| 171 | 172 | }); |
| 172 | 173 | console.log(params); |
| 173 | 174 | jName = params[0].split("\\")[0]; |
| ... | ... | @@ -180,18 +181,18 @@ |
| 180 | 181 | // 把渲染好的模版html文本追加到表格中 |
| 181 | 182 | $('#forms .ludan_1').html(ludan_1); |
| 182 | 183 | //$('#forms .ludan_4').html(ludan_4); |
| 183 | - }); | |
| 184 | + }); | |
| 184 | 185 | $post('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2],date:date},function(result){ |
| 185 | - getTime(result); | |
| 186 | - var ludan_2 = template('ludan_2',{list:result}); | |
| 187 | - // 把渲染好的模版html文本追加到表格中 | |
| 188 | - $('#forms .ludan_2').html(ludan_2); | |
| 186 | + getTime(result); | |
| 187 | + var ludan_2 = template('ludan_2',{list:result}); | |
| 188 | + // 把渲染好的模版html文本追加到表格中 | |
| 189 | + $('#forms .ludan_2').html(ludan_2); | |
| 189 | 190 | }); |
| 190 | 191 | $post('/realSchedule/findKMBC',{jName:jName,clZbh:params[1],lpName:params[2],date:date},function(result){ |
| 191 | 192 | var ludan_3 = template('ludan_3',result); |
| 192 | 193 | $('#forms .ludan_3').html(ludan_3); |
| 193 | 194 | }); |
| 194 | - | |
| 195 | + | |
| 195 | 196 | }); |
| 196 | 197 | |
| 197 | 198 | $("#export").on("click",function(){ |
| ... | ... | @@ -227,22 +228,22 @@ |
| 227 | 228 | } |
| 228 | 229 | } |
| 229 | 230 | }); |
| 230 | - } | |
| 231 | - }); | |
| 232 | -</script> | |
| 233 | -<script type="text/html" id="list_info"> | |
| 234 | - {{each list as obj i}} | |
| 235 | - <tr> | |
| 236 | - <td width="45%">{{obj[4]}}\{{obj[1]}}</td> | |
| 237 | - <td width="32%">{{obj[2]}}</td> | |
| 238 | - <td width="23%">{{obj[3]}}<input type="hidden" id="{{obj[2]}}" value="{{obj[0]}}"></td> | |
| 239 | - </tr> | |
| 240 | - {{/each}} | |
| 241 | - {{if list.length == 0}} | |
| 242 | - <tr> | |
| 243 | - <td colspan="3"><h6 class="muted">没有找到相关数据</h6></td> | |
| 244 | - </tr> | |
| 245 | - {{/if}} | |
| 231 | + } | |
| 232 | + }); | |
| 233 | +</script> | |
| 234 | +<script type="text/html" id="list_info"> | |
| 235 | + {{each list as obj i}} | |
| 236 | + <tr> | |
| 237 | + <td width="45%">{{obj[4]}}\{{obj[1]}}</td> | |
| 238 | + <td width="32%">{{obj[2]}}</td> | |
| 239 | + <td width="23%">{{obj[3]}}<input type="hidden" id="{{obj[2]}}" value="{{obj[0]}}"></td> | |
| 240 | + </tr> | |
| 241 | + {{/each}} | |
| 242 | + {{if list.length == 0}} | |
| 243 | + <tr> | |
| 244 | + <td colspan="3"><h6 class="muted">没有找到相关数据</h6></td> | |
| 245 | + </tr> | |
| 246 | + {{/if}} | |
| 246 | 247 | </script> |
| 247 | 248 | <script type="text/html" id="ludan_1"> |
| 248 | 249 | <tr> |
| ... | ... | @@ -303,31 +304,31 @@ |
| 303 | 304 | <td colspan="1">快</td> |
| 304 | 305 | <td colspan="1">慢</td> |
| 305 | 306 | </tr> |
| 306 | -</script> | |
| 307 | -<script type="text/html" id="ludan_2"> | |
| 308 | - {{each list as obj i}} | |
| 309 | - <tr> | |
| 310 | - <td>{{i+1}}</td> | |
| 311 | - <td>{{obj.jName}}</td> | |
| 312 | - <td>{{obj.sName}}</td> | |
| 313 | - <td> </td> | |
| 314 | - <td>{{obj.qdzName}}</td> | |
| 315 | - <td>{{obj.zdzName}}</td> | |
| 316 | - <td>{{obj.fcsj}}</td> | |
| 317 | - <td>{{obj.fcsjActual}}</td> | |
| 318 | - <td>{{obj.zdsj}}</td> | |
| 319 | - <td>{{obj.zdsjActual}}</td> | |
| 320 | - <td>{{obj.fast}}</td> | |
| 321 | - <td>{{obj.slow}}</td> | |
| 307 | +</script> | |
| 308 | +<script type="text/html" id="ludan_2"> | |
| 309 | + {{each list as obj i}} | |
| 310 | + <tr> | |
| 311 | + <td>{{i+1}}</td> | |
| 312 | + <td>{{obj.jName}}</td> | |
| 313 | + <td>{{obj.sName}}</td> | |
| 314 | + <td> </td> | |
| 315 | + <td>{{obj.qdzName}}</td> | |
| 316 | + <td>{{obj.zdzName}}</td> | |
| 317 | + <td>{{obj.fcsj}}</td> | |
| 318 | + <td>{{obj.fcsjActual}}</td> | |
| 319 | + <td>{{obj.zdsj}}</td> | |
| 320 | + <td>{{obj.zdsjActual}}</td> | |
| 321 | + <td>{{obj.fast}}</td> | |
| 322 | + <td>{{obj.slow}}</td> | |
| 322 | 323 | <td>{{obj.jhlc}}</td> |
| 323 | - <td>{{obj.remarks}}</td> | |
| 324 | - </tr> | |
| 324 | + <td>{{obj.remarks}}</td> | |
| 325 | + </tr> | |
| 325 | 326 | {{/each}} |
| 326 | 327 | {{if list.length == 0}} |
| 327 | 328 | <tr> |
| 328 | 329 | <td colspan="14"><h6 class="muted">没有找到相关数据</h6></td> |
| 329 | 330 | </tr> |
| 330 | - {{/if}} | |
| 331 | + {{/if}} | |
| 331 | 332 | </script> |
| 332 | 333 | <script type="text/html" id="ludan_3"> |
| 333 | 334 | <tr> | ... | ... |
src/main/resources/static/pages/permission/role/companyAuthority.html
0 → 100644
| 1 | +<style> | |
| 2 | + .cmpy-auth-card { | |
| 3 | + width: 760px; | |
| 4 | + background: #fff; | |
| 5 | + margin: auto; | |
| 6 | + padding: 15px; | |
| 7 | + box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); | |
| 8 | + } | |
| 9 | + | |
| 10 | + .cmpy-auth-card .yunyin-company-panel:last-child { | |
| 11 | + border-bottom: none; | |
| 12 | + padding-bottom: 0px; | |
| 13 | + } | |
| 14 | + | |
| 15 | + .yunyin-company-panel { | |
| 16 | + border-bottom: 1px solid #e9e5e5; | |
| 17 | + padding-bottom: 5px; | |
| 18 | + | |
| 19 | + user-select:none; | |
| 20 | + } | |
| 21 | + | |
| 22 | + .yunyin-company-panel .company { | |
| 23 | + font-size: 13px; | |
| 24 | + } | |
| 25 | + | |
| 26 | + .yunyin-company-panel .sub-company { | |
| 27 | + display: inline-block; | |
| 28 | + text-align: center; | |
| 29 | + padding: 5px 15px; | |
| 30 | + border-radius: 5px !important; | |
| 31 | + color: #5d5c5c; | |
| 32 | + font-size: 13px; | |
| 33 | + background: linear-gradient(to bottom, #fafafa, #eeeeee); | |
| 34 | + cursor: pointer; | |
| 35 | + border: 1px solid #eeeeee; | |
| 36 | + } | |
| 37 | + | |
| 38 | + .yunyin-company-panel .sub-company.active { | |
| 39 | + background: linear-gradient(to bottom, #2ab4c0, #229ea9); | |
| 40 | + color: #fdfdfd; | |
| 41 | + } | |
| 42 | +</style> | |
| 43 | + | |
| 44 | +<div id="roleCompanyAuthority"> | |
| 45 | + | |
| 46 | + <div class="page-head"> | |
| 47 | + <div class="page-title"> | |
| 48 | + <h1>模块配置</h1> | |
| 49 | + </div> | |
| 50 | + </div> | |
| 51 | + | |
| 52 | + <ul class="page-breadcrumb breadcrumb"> | |
| 53 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i | |
| 54 | + class="fa fa-circle"></i></li> | |
| 55 | + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> | |
| 56 | + <li><a href="list.html" data-pjax>角色管理</a> <i class="fa fa-circle"></i></li> | |
| 57 | + <li><span class="active">分公司数据权限</span></li> | |
| 58 | + </ul> | |
| 59 | + | |
| 60 | + <div class="cmpy-auth-card"> | |
| 61 | + | |
| 62 | + <h4>角色信息</h4> | |
| 63 | + <table class="table"> | |
| 64 | + <tr> | |
| 65 | + <td> | |
| 66 | + 代码:<span id="roleCode"></span> | |
| 67 | + </td> | |
| 68 | + <td> | |
| 69 | + 名称:<span id="roleName"></span> | |
| 70 | + </td> | |
| 71 | + </tr> | |
| 72 | + </table> | |
| 73 | + </div> | |
| 74 | + <br><br> | |
| 75 | + <div class="cmpy-auth-card cmpy-list"> | |
| 76 | + </div> | |
| 77 | + | |
| 78 | + <div class="cmpy-auth-card" style="text-align: right;"> | |
| 79 | + <button type="button" class="btn btn-default">返回</button> | |
| 80 | + <button type="button" class="btn btn-primary saveBtn" ><i class="fa fa-check"></i>保存</button> | |
| 81 | + </div> | |
| 82 | + | |
| 83 | + <script id="role-company-authority-temp" type="text/html"> | |
| 84 | + {{each list as obj i}} | |
| 85 | + <div class="yunyin-company-panel"> | |
| 86 | + <h5 class="company">{{obj.name}}</h5> | |
| 87 | + {{each obj.childs as fgs i}} | |
| 88 | + <div class="sub-company" data-company="{{obj.name}}" data-id="{{fgs.upCode}}_{{fgs.businessCode}}">{{fgs.businessName}}</div> | |
| 89 | + {{/each}} | |
| 90 | + </div> | |
| 91 | + {{/each}} | |
| 92 | + </script> | |
| 93 | + | |
| 94 | +</div> | |
| 95 | + | |
| 96 | +<script> | |
| 97 | +$(function () { | |
| 98 | + var id = $.url().param('no') | |
| 99 | + ,roleObj; | |
| 100 | + | |
| 101 | + if(!id){ | |
| 102 | + alert('缺少主键'); | |
| 103 | + } | |
| 104 | + else{ | |
| 105 | + $.get('/role/'+id , function(obj){ | |
| 106 | + $('#roleCompanyAuthority #roleCode').text(obj.codeName); | |
| 107 | + $('#roleCompanyAuthority #roleName').text(obj.roleName); | |
| 108 | + }); | |
| 109 | + } | |
| 110 | + | |
| 111 | + | |
| 112 | + $.get('/business/all', function (rs) { | |
| 113 | + var baseCode; | |
| 114 | + //找到跟节点 | |
| 115 | + $.each(rs, function () { | |
| 116 | + if(this.upCode == 0){ | |
| 117 | + baseCode=this.businessCode; | |
| 118 | + return false; | |
| 119 | + } | |
| 120 | + }); | |
| 121 | + if(!baseCode){ | |
| 122 | + alert('大爷找不到跟节点,数据有问题吧!!!'); | |
| 123 | + return; | |
| 124 | + } | |
| 125 | + //提取二级节点 | |
| 126 | + var secondMap={}; | |
| 127 | + $.each(rs, function () { | |
| 128 | + if(this.upCode==baseCode){ | |
| 129 | + secondMap[this.businessCode] = { | |
| 130 | + name: this.businessName, | |
| 131 | + childs: [] | |
| 132 | + }; | |
| 133 | + } | |
| 134 | + }); | |
| 135 | + //分公司节点 | |
| 136 | + $.each(rs, function () { | |
| 137 | + if(secondMap[this.upCode]) | |
| 138 | + secondMap[this.upCode].childs.push(this); | |
| 139 | + }); | |
| 140 | + | |
| 141 | + //排序 | |
| 142 | + for(var sid in secondMap){ | |
| 143 | + secondMap[sid].childs.sort(naturalSort); | |
| 144 | + } | |
| 145 | + | |
| 146 | + var htmlStr=template('role-company-authority-temp', {list: get_vals(secondMap)}); | |
| 147 | + $('#roleCompanyAuthority .cmpy-list').html(htmlStr); | |
| 148 | + | |
| 149 | + //查询公司权限信息 | |
| 150 | + $get('/companyAuthority/all', {roleId_eq: id}, function (rs) { | |
| 151 | + //console.log(rs); | |
| 152 | + var dataId; | |
| 153 | + $.each(rs, function () { | |
| 154 | + dataId=this.companyCode+'_'+this.subCompanyCode; | |
| 155 | + $('.cmpy-list div.sub-company[data-id='+dataId+']').addClass('active'); | |
| 156 | + }); | |
| 157 | + }); | |
| 158 | + }); | |
| 159 | + | |
| 160 | + $('#roleCompanyAuthority').on('click', '.cmpy-list .sub-company', function () { | |
| 161 | + if($(this).hasClass('active')) | |
| 162 | + $(this).removeClass('active'); | |
| 163 | + else | |
| 164 | + $(this).addClass('active'); | |
| 165 | + }); | |
| 166 | + | |
| 167 | + var get_vals = function(json) { | |
| 168 | + var array = []; | |
| 169 | + for (var key in json) { | |
| 170 | + array.push(json[key]); | |
| 171 | + } | |
| 172 | + | |
| 173 | + return array; | |
| 174 | + } | |
| 175 | + | |
| 176 | + var naturalSort=function (a, b) { | |
| 177 | + return a.businessCode.localeCompare(b.businessCode); | |
| 178 | + } | |
| 179 | + | |
| 180 | + //保存 | |
| 181 | + $('#roleCompanyAuthority .saveBtn').on('click', function () { | |
| 182 | + var ats=$('.cmpy-list div.sub-company.active', '#roleCompanyAuthority') | |
| 183 | + ,data=[]; | |
| 184 | + var code; | |
| 185 | + $.each(ats, function () { | |
| 186 | + code = $(this).data('id').split('_'); | |
| 187 | + data.push({ | |
| 188 | + companyCode: code[0], | |
| 189 | + subCompanyCode: code[1], | |
| 190 | + companyName: $(this).data('company'), | |
| 191 | + subCompanyName: $(this).text() | |
| 192 | + }); | |
| 193 | + }); | |
| 194 | + | |
| 195 | + $post('/companyAuthority/save', {roleId: id, authJsonStr: JSON.stringify(data)}, function (rs) { | |
| 196 | + alert('保存成功!'); | |
| 197 | + }) | |
| 198 | + }); | |
| 199 | +}); | |
| 200 | +</script> | |
| 0 | 201 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/permission/role/list.html
| ... | ... | @@ -66,9 +66,15 @@ |
| 66 | 66 | <a href="settings.html?no={{role.id}}" data-pjax class=" font-blue " |
| 67 | 67 | style="display: inline-block; margin-right: 5px;"> <i |
| 68 | 68 | class="fa fa-meh-o"> </i> 模块配置 |
| 69 | - </a> <a href="javascript:;" class=" font-blue " | |
| 70 | - style="display: inline-block;" > <i class="fa fa-key"> | |
| 71 | - </i> 分配资源 | |
| 69 | + </a> | |
| 70 | + <a href="javascript:;" class=" font-blue " | |
| 71 | + style="display: inline-block;color: #aaaaaa !important;" > <i class="fa fa-key"> | |
| 72 | + </i> 系统资源权限 | |
| 73 | + </a> | |
| 74 | + | |
| 75 | + <hr> | |
| 76 | + <a href="companyAuthority.html?no={{role.id}}" data-pjax class="font-blue" | |
| 77 | + style="display: inline-block; font-size: 12px;" > 分公司数据权限 | |
| 72 | 78 | </a> |
| 73 | 79 | </div> |
| 74 | 80 | </div> | ... | ... |
src/main/resources/static/real_control_v2/js/data/data_gps.js
src/main/resources/static/real_control_v2/mapmonitor/css/real.css
| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | /**/ |
| 43 | 43 | .real_bottom_panel{ |
| 44 | 44 | position: absolute !important; |
| 45 | - height: 18px; | |
| 45 | + height: 180px; | |
| 46 | 46 | width: 100%; |
| 47 | 47 | width: calc(100% - 342px); |
| 48 | 48 | bottom: 2px !important; |
| ... | ... | @@ -111,7 +111,8 @@ |
| 111 | 111 | height: calc(100% - 7px); |
| 112 | 112 | overflow: auto; |
| 113 | 113 | padding-top: 7px; |
| 114 | - font-size: 13px | |
| 114 | + font-size: 13px; | |
| 115 | + position: relative; | |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | 118 | .real_br_cont .uk-form .uk-form-row{ |
| ... | ... | @@ -163,4 +164,145 @@ |
| 163 | 164 | background-color: #fff; |
| 164 | 165 | border-radius: 4px; |
| 165 | 166 | box-shadow: 0 2px 5px rgba(0,0,0,0.1); |
| 167 | +} | |
| 168 | + | |
| 169 | +.gps_info_win p{ | |
| 170 | + margin: 9px 0; | |
| 171 | + font-size: 13px; | |
| 172 | +} | |
| 173 | + | |
| 174 | +.gps_info_win h4,.gps_info_win h5{ | |
| 175 | + color: #0E6AF9; | |
| 176 | + margin: 10px 0; | |
| 177 | +} | |
| 178 | + | |
| 179 | +.gps_info_win .date-str{ | |
| 180 | + color: gray;font-size: 12px; | |
| 181 | +} | |
| 182 | + | |
| 183 | +.gps_info_win a{ | |
| 184 | + color:#878887;font-size:12px; | |
| 185 | +} | |
| 186 | + | |
| 187 | + | |
| 188 | +.spinner { | |
| 189 | + margin: 50px auto; | |
| 190 | + width: 50px; | |
| 191 | + height: 40px; | |
| 192 | + text-align: center; | |
| 193 | + font-size: 10px; | |
| 194 | +} | |
| 195 | + | |
| 196 | +.spinner > div { | |
| 197 | + background-color: #69D7E1; | |
| 198 | + height: 100%; | |
| 199 | + width: 6px; | |
| 200 | + display: inline-block; | |
| 201 | + | |
| 202 | + -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out; | |
| 203 | + animation: sk-stretchdelay 1.2s infinite ease-in-out; | |
| 204 | +} | |
| 205 | + | |
| 206 | +.spinner .rect2 { | |
| 207 | + -webkit-animation-delay: -1.1s; | |
| 208 | + animation-delay: -1.1s; | |
| 209 | +} | |
| 210 | + | |
| 211 | +.spinner .rect3 { | |
| 212 | + -webkit-animation-delay: -1.0s; | |
| 213 | + animation-delay: -1.0s; | |
| 214 | +} | |
| 215 | + | |
| 216 | +.spinner .rect4 { | |
| 217 | + -webkit-animation-delay: -0.9s; | |
| 218 | + animation-delay: -0.9s; | |
| 219 | +} | |
| 220 | + | |
| 221 | +.spinner .rect5 { | |
| 222 | + -webkit-animation-delay: -0.8s; | |
| 223 | + animation-delay: -0.8s; | |
| 224 | +} | |
| 225 | + | |
| 226 | +@-webkit-keyframes sk-stretchdelay { | |
| 227 | + 0%, 40%, 100% { -webkit-transform: scaleY(0.4) } | |
| 228 | + 20% { -webkit-transform: scaleY(1.0) } | |
| 229 | +} | |
| 230 | + | |
| 231 | +@keyframes sk-stretchdelay { | |
| 232 | + 0%, 40%, 100% { | |
| 233 | + transform: scaleY(0.4); | |
| 234 | + -webkit-transform: scaleY(0.4); | |
| 235 | + } 20% { | |
| 236 | + transform: scaleY(1.0); | |
| 237 | + -webkit-transform: scaleY(1.0); | |
| 238 | + } | |
| 239 | +} | |
| 240 | + | |
| 241 | +.sk-cube-grid { | |
| 242 | + width: 40px; | |
| 243 | + height: 40px; | |
| 244 | + margin: 100px auto; | |
| 245 | +} | |
| 246 | + | |
| 247 | +.sk-cube-grid .sk-cube { | |
| 248 | + width: 33%; | |
| 249 | + height: 33%; | |
| 250 | + background-color: #69D7E1; | |
| 251 | + float: left; | |
| 252 | + -webkit-animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; | |
| 253 | + animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; | |
| 254 | +} | |
| 255 | +.sk-cube-grid .sk-cube1 { | |
| 256 | + -webkit-animation-delay: 0.2s; | |
| 257 | + animation-delay: 0.2s; } | |
| 258 | +.sk-cube-grid .sk-cube2 { | |
| 259 | + -webkit-animation-delay: 0.3s; | |
| 260 | + animation-delay: 0.3s; } | |
| 261 | +.sk-cube-grid .sk-cube3 { | |
| 262 | + -webkit-animation-delay: 0.4s; | |
| 263 | + animation-delay: 0.4s; } | |
| 264 | +.sk-cube-grid .sk-cube4 { | |
| 265 | + -webkit-animation-delay: 0.1s; | |
| 266 | + animation-delay: 0.1s; } | |
| 267 | +.sk-cube-grid .sk-cube5 { | |
| 268 | + -webkit-animation-delay: 0.2s; | |
| 269 | + animation-delay: 0.2s; } | |
| 270 | +.sk-cube-grid .sk-cube6 { | |
| 271 | + -webkit-animation-delay: 0.3s; | |
| 272 | + animation-delay: 0.3s; } | |
| 273 | +.sk-cube-grid .sk-cube7 { | |
| 274 | + -webkit-animation-delay: 0s; | |
| 275 | + animation-delay: 0s; } | |
| 276 | +.sk-cube-grid .sk-cube8 { | |
| 277 | + -webkit-animation-delay: 0.1s; | |
| 278 | + animation-delay: 0.1s; } | |
| 279 | +.sk-cube-grid .sk-cube9 { | |
| 280 | + -webkit-animation-delay: 0.2s; | |
| 281 | + animation-delay: 0.2s; } | |
| 282 | + | |
| 283 | +@-webkit-keyframes sk-cubeGridScaleDelay { | |
| 284 | + 0%, 70%, 100% { | |
| 285 | + -webkit-transform: scale3D(1, 1, 1); | |
| 286 | + transform: scale3D(1, 1, 1); | |
| 287 | + } 35% { | |
| 288 | + -webkit-transform: scale3D(0, 0, 1); | |
| 289 | + transform: scale3D(0, 0, 1); | |
| 290 | + } | |
| 291 | +} | |
| 292 | + | |
| 293 | +@keyframes sk-cubeGridScaleDelay { | |
| 294 | + 0%, 70%, 100% { | |
| 295 | + -webkit-transform: scale3D(1, 1, 1); | |
| 296 | + transform: scale3D(1, 1, 1); | |
| 297 | + } 35% { | |
| 298 | + -webkit-transform: scale3D(0, 0, 1); | |
| 299 | + transform: scale3D(0, 0, 1); | |
| 300 | + } | |
| 301 | +} | |
| 302 | +.sk-cube-grid._center{ | |
| 303 | + position: absolute; | |
| 304 | + top: 30%; | |
| 305 | + left: 50%; | |
| 306 | + transform: translate(-50%, -50%); | |
| 307 | + -webkit-transform: translate(-50%, -50%); | |
| 166 | 308 | } |
| 167 | 309 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/js/config.js
| ... | ... | @@ -46,9 +46,8 @@ var gb_map_config=(function () { |
| 46 | 46 | $('.map_config_wrap').html(formHtml); |
| 47 | 47 | |
| 48 | 48 | //颜色选择器 |
| 49 | - $('.map_config_wrap .color_block').each(function () { | |
| 50 | - var c=$('.sp-placeholder-color',this).css('background-color'); | |
| 51 | - var that=this; | |
| 49 | + $('.map_config_wrap .color_block .sp-placeholder .sp-placeholder-color').each(function () { | |
| 50 | + var c=$(this).css('background-color'); | |
| 52 | 51 | $(this).spectrum({ |
| 53 | 52 | color: c, |
| 54 | 53 | showInput: true, |
| ... | ... | @@ -57,15 +56,74 @@ var gb_map_config=(function () { |
| 57 | 56 | preferredFormat: "rgb", |
| 58 | 57 | showAlpha: true, |
| 59 | 58 | change: function (color) { |
| 60 | - $('.sp-placeholder-color',that).css('background-color', color); | |
| 59 | + $(this).css('background-color', color); | |
| 60 | + //set attr | |
| 61 | + recursion_set_attr(defaultConfig, $(this).data('name'), color.toString()); | |
| 62 | + //重新渲染地图覆盖物 | |
| 63 | + gb_map_overlay_mge.reDraw(); | |
| 61 | 64 | } |
| 62 | 65 | }); |
| 63 | 66 | }); |
| 64 | 67 | |
| 68 | + $('.map_config_wrap form input').on('change', configChangeHandler); | |
| 65 | 69 | |
| 66 | 70 | }); |
| 67 | 71 | } |
| 68 | 72 | |
| 73 | + var configChangeHandler = function () { | |
| 74 | + //console.log('configChangeHandler..',this); | |
| 75 | + var name = $(this).attr('name') | |
| 76 | + ,val = $(this).attr('value'); | |
| 77 | + | |
| 78 | + if(!name) | |
| 79 | + return; | |
| 80 | + | |
| 81 | + handler[name] && handler[name](val); | |
| 82 | + }; | |
| 83 | + | |
| 84 | + var handler={ | |
| 85 | + map_type: changeMapType | |
| 86 | + }; | |
| 87 | + | |
| 88 | + //切换地图类型 | |
| 89 | + function changeMapType(val) { | |
| 90 | + gb_map_imap.changeMap(val, function () { | |
| 91 | + gb_map_overlay_mge.reDraw(); | |
| 92 | + }); | |
| 93 | + } | |
| 94 | + | |
| 95 | + function recursion_get_attr(data, attr){ | |
| 96 | + var ats = attr.split('.'), | |
| 97 | + val = data; | |
| 98 | + | |
| 99 | + $.each(ats, function (i, a) { | |
| 100 | + val=val[a]; | |
| 101 | + | |
| 102 | + if(!val) | |
| 103 | + return false; | |
| 104 | + }); | |
| 105 | + | |
| 106 | + return val; | |
| 107 | + } | |
| 108 | + | |
| 109 | + function recursion_set_attr(data, attr, value) { | |
| 110 | + var ats = attr.split('.'), | |
| 111 | + tempVal = data | |
| 112 | + ,len = ats.length; | |
| 113 | + | |
| 114 | + $.each(ats, function (i, a) { | |
| 115 | + if(i == len -1){ | |
| 116 | + tempVal[a] = value; | |
| 117 | + return false; | |
| 118 | + } | |
| 119 | + else | |
| 120 | + tempVal=tempVal[a]; | |
| 121 | + | |
| 122 | + if(!tempVal) | |
| 123 | + return false; | |
| 124 | + }); | |
| 125 | + } | |
| 126 | + | |
| 69 | 127 | return { |
| 70 | 128 | getConfig: function () { |
| 71 | 129 | return defaultConfig; | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/js/map/iMap.js
| ... | ... | @@ -16,27 +16,20 @@ var gb_map_imap = (function () { |
| 16 | 16 | currentMap = name; |
| 17 | 17 | return mapProxy; |
| 18 | 18 | }, |
| 19 | - changeDefault: function (mapName) { | |
| 19 | + changeMap: function (mapName, cb) { | |
| 20 | 20 | if (mapName == currentMap) |
| 21 | 21 | return; |
| 22 | 22 | if (maps[mapName]) { |
| 23 | 23 | //原地图 destroy |
| 24 | 24 | var oldMap = maps[currentMap].instance; |
| 25 | 25 | oldMap.destroy && oldMap.destroy(); |
| 26 | - $(gb_map_consts.mapContainer).html(''); | |
| 27 | - //解除实时路况按钮点击事件 | |
| 28 | - $(gb_map_consts.trafficBtn).unbind('click'); | |
| 29 | - | |
| 30 | 26 | //新地图 INIT |
| 31 | 27 | var text = maps[mapName].text; |
| 32 | 28 | //layer.msg('正在切换到' + text + '...', {icon : 16,shade : [ 0.6, '#393D49' ],time : 0}); |
| 33 | 29 | var newMap = maps[mapName].instance; |
| 34 | - newMap.init(); | |
| 35 | - setText(text); | |
| 30 | + newMap.init(cb); | |
| 36 | 31 | |
| 37 | 32 | currentMap = mapName; |
| 38 | - //收拢线路 | |
| 39 | - $('.mapRightWrap .collapse.in').collapse('hide'); | |
| 40 | 33 | } else |
| 41 | 34 | alertErr('不存在的地图实例' + mapName); |
| 42 | 35 | }, |
| ... | ... | @@ -87,24 +80,19 @@ var gb_map_imap = (function () { |
| 87 | 80 | case 0: |
| 88 | 81 | if (g.upDown == 0) { |
| 89 | 82 | //营运上行 |
| 90 | - colours['bgColor'] = 'rgba(94, 150, 210, 1)'; | |
| 83 | + colours['bgColor'] = gb_map_config.getConfig().carIcon.color.up; | |
| 91 | 84 | colours['shadow'] = 'rgba(94, 150, 210, 0.3)'; |
| 92 | 85 | } |
| 93 | 86 | else if (g.upDown == 1) { |
| 94 | 87 | //营运下行 |
| 95 | - colours['bgColor'] = 'rgba(201, 33, 33, 1)'; | |
| 88 | + colours['bgColor'] = gb_map_config.getConfig().carIcon.color.down; | |
| 96 | 89 | colours['shadow'] = 'rgba(201, 33, 33, 0.3)'; |
| 97 | 90 | } |
| 98 | - else { | |
| 99 | - //未知走向 | |
| 100 | - colours['bgColor'] = 'rgba(0, 0, 0, 1)'; | |
| 101 | - colours['shadow'] = 'rgba(0, 0, 0, 0.3)'; | |
| 102 | - } | |
| 103 | 91 | break; |
| 104 | 92 | |
| 105 | 93 | default: |
| 106 | 94 | //非营运 |
| 107 | - colours['bgColor'] = 'rgba(136, 133, 133, 1)'; | |
| 95 | + colours['bgColor'] = gb_map_config.getConfig().carIcon.color.nonOperation; | |
| 108 | 96 | colours['shadow'] = 'rgba(136, 133, 133, 0.3)'; |
| 109 | 97 | break; |
| 110 | 98 | } | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/js/map/platform/baidu.js
| ... | ... | @@ -13,7 +13,7 @@ var gb_map_baidu = (function(){ |
| 13 | 13 | var buffAreas = {}; |
| 14 | 14 | var baiduInstance = { |
| 15 | 15 | //初始化 |
| 16 | - init: function(){ | |
| 16 | + init: function(cb){ | |
| 17 | 17 | if(!window.BMap){ |
| 18 | 18 | alert('地图没有加载成功,请确认是否能正常连接外网!!'); |
| 19 | 19 | return; |
| ... | ... | @@ -23,7 +23,9 @@ var gb_map_baidu = (function(){ |
| 23 | 23 | map.centerAndZoom(new BMap.Point(gb_map_consts.center_point.lng, gb_map_consts.center_point.lat), 12); |
| 24 | 24 | map.enableScrollWheelZoom(); |
| 25 | 25 | |
| 26 | - window.localStorage.setItem('real_map', 'baidu'); | |
| 26 | + | |
| 27 | + | |
| 28 | + //window.localStorage.setItem('real_map', 'baidu'); | |
| 27 | 29 | |
| 28 | 30 | // 路况控件 |
| 29 | 31 | /* var ctrl = new BMapLib.TrafficControl(); |
| ... | ... | @@ -52,11 +54,11 @@ var gb_map_baidu = (function(){ |
| 52 | 54 | destroy: function(){ |
| 53 | 55 | realMarkers = {}; |
| 54 | 56 | linePolyline = []; |
| 55 | - }, | |
| 57 | + }/*, | |
| 56 | 58 | clear: function(){ |
| 57 | 59 | realMarkers = {}; |
| 58 | 60 | map.clearOverlays(); |
| 59 | - }, | |
| 61 | + }*/, | |
| 60 | 62 | //画线路图层 |
| 61 | 63 | drawLine: function(opt){ |
| 62 | 64 | if(polylines[opt.id]) |
| ... | ... | @@ -128,6 +130,13 @@ var gb_map_baidu = (function(){ |
| 128 | 130 | } |
| 129 | 131 | }); |
| 130 | 132 | }, |
| 133 | + clearAll: function () { | |
| 134 | + //清除所有覆盖物 | |
| 135 | + realMarkers = {}; | |
| 136 | + polylines={}; | |
| 137 | + map.clearOverlays(); | |
| 138 | + | |
| 139 | + }, | |
| 131 | 140 | showGpsMarker:function (opt) { |
| 132 | 141 | var chs = opt.chs; |
| 133 | 142 | for(var device in realMarkers){ |
| ... | ... | @@ -219,9 +228,9 @@ var gb_map_baidu = (function(){ |
| 219 | 228 | marker.infoWindow = new BMap.InfoWindow(bd_gps_info_win_opts); |
| 220 | 229 | marker.gpsData = gpsData; |
| 221 | 230 | //click |
| 222 | - /*marker.addEventListener('click', function(){ | |
| 231 | + marker.addEventListener('click', function(){ | |
| 223 | 232 | bdOpenWindow(this); |
| 224 | - });*/ | |
| 233 | + }); | |
| 225 | 234 | //mouseover |
| 226 | 235 | marker.addEventListener('mouseover', function(){ |
| 227 | 236 | setTop(this); |
| ... | ... | @@ -273,9 +282,13 @@ var gb_map_baidu = (function(){ |
| 273 | 282 | } |
| 274 | 283 | |
| 275 | 284 | function bdOpenWindow(marker){ |
| 276 | - marker.gpsData.fromNow = moment(marker.gpsData.timestamp).fromNow(); | |
| 285 | + var gps = marker.gpsData; | |
| 286 | + //线路名 | |
| 287 | + gps.lineName = gb_data_basic.lineCode2NameAll()[gps.lineId]; | |
| 288 | + //时间 | |
| 289 | + gps.dateStr = moment(gps.timestamp).format('YYYY-MM-DD HH:mm:ss'); | |
| 277 | 290 | |
| 278 | - marker.infoWindow.setContent(gb_map_overlay_mge.map_gps_win_temp(marker.gpsData)); | |
| 291 | + marker.infoWindow.setContent(gb_map_overlay_mge.map_gps_win_temp(gps)); | |
| 279 | 292 | map.openInfoWindow(marker.infoWindow, marker.point); |
| 280 | 293 | } |
| 281 | 294 | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/js/map/platform/gaode.js
| ... | ... | @@ -16,11 +16,11 @@ var gb_map_gaode = (function() { |
| 16 | 16 | var topMarkr; |
| 17 | 17 | var realMarkers = {}; |
| 18 | 18 | //线路路由线条 |
| 19 | - var linePolyline; | |
| 19 | + var polylines={}; | |
| 20 | 20 | //实时路况是否显示 |
| 21 | 21 | var traffVisible; |
| 22 | 22 | var gaodeInstance = { |
| 23 | - init : function() { | |
| 23 | + init : function(cb) { | |
| 24 | 24 | var $mapCon = $(gb_map_consts.mapContainer); |
| 25 | 25 | $mapCon.html(mapLoadAnim); |
| 26 | 26 | //设置样式 |
| ... | ... | @@ -31,14 +31,14 @@ var gb_map_gaode = (function() { |
| 31 | 31 | map.setZoomAndCenter(14, [ gb_map_consts.center_point.lng, gb_map_consts.center_point.lat ]); |
| 32 | 32 | // 加载完成 |
| 33 | 33 | AMap.event.addListener(map, 'complete', function() { |
| 34 | - layer.closeAll(); | |
| 35 | - window.localStorage.setItem('real_map', 'gaode'); | |
| 34 | + //window.localStorage.setItem('real_map', 'gaode'); | |
| 36 | 35 | /*storage.setItem('real_map', REAL_GAODE_TEXT); |
| 37 | 36 | $('.sk-cube-grid._center').remove();*/ |
| 37 | + cb && cb(); | |
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | 40 | // 实时路况图层 |
| 41 | - var trafficLayer = new AMap.TileLayer.Traffic(); | |
| 41 | + /*var trafficLayer = new AMap.TileLayer.Traffic(); | |
| 42 | 42 | trafficLayer.setMap(map); |
| 43 | 43 | trafficLayer.hide(); |
| 44 | 44 | |
| ... | ... | @@ -54,7 +54,7 @@ var gb_map_gaode = (function() { |
| 54 | 54 | $(this).addClass('active'); |
| 55 | 55 | hideLinePolyline(); |
| 56 | 56 | } |
| 57 | - }); | |
| 57 | + });*/ | |
| 58 | 58 | }, |
| 59 | 59 | setStyle : function() { |
| 60 | 60 | $('.mapRightWrap').addClass('gaode'); |
| ... | ... | @@ -67,50 +67,88 @@ var gb_map_gaode = (function() { |
| 67 | 67 | $('.mapTools').removeClass('gaode'); |
| 68 | 68 | $('.leftUtils').removeClass('gaode'); |
| 69 | 69 | }, |
| 70 | - clear: function(){ | |
| 70 | + clearAll: function () { | |
| 71 | + realMarkers = {}; | |
| 72 | + polylines={}; | |
| 73 | + map.clearMap(); | |
| 74 | + } | |
| 75 | + /*clear: function(){ | |
| 71 | 76 | realMarkers = {}; |
| 72 | 77 | map.clearMap(); |
| 73 | 78 | linePolyline = []; |
| 74 | - }, | |
| 75 | - drawLine: function(opts){ | |
| 76 | - linePolyline = []; | |
| 79 | + }*/, | |
| 80 | + drawLine: function(opt){ | |
| 81 | + //linePolyline = []; | |
| 82 | + var pos = [], temps; | |
| 83 | + var route = opt.upDown==0?opt.route.up_gcj:opt.route.down_gcj; | |
| 77 | 84 | |
| 78 | - map.clearMap(); | |
| 85 | + $.each(route.split(','), function(){ | |
| 86 | + temps = this.split(' '); | |
| 87 | + pos.push([temps[0], temps[1]]); | |
| 88 | + }); | |
| 79 | 89 | |
| 80 | - var upArr = [], downArr = []; | |
| 81 | - var upLineOps = {path: upArr, strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5} | |
| 82 | - ,downLineOps = {path: downArr, strokeColor:"red", strokeWeight:6, strokeOpacity:0.5}; | |
| 83 | - var route = opts.route; | |
| 84 | - //上行 | |
| 85 | - if(route.up){ | |
| 86 | - $.each(route.up_gcj.split(','), function(){ | |
| 87 | - tempArray = this.split(' '); | |
| 88 | - upArr.push([tempArray[0], tempArray[1]]); | |
| 89 | - }); | |
| 90 | - var upLine = new AMap.Polyline(upLineOps); | |
| 91 | - //保存线条引用 | |
| 92 | - linePolyline.push(upLine); | |
| 93 | - upLine.setMap(map); | |
| 94 | - map.setCenter(upArr[parseInt(upArr.length / 2)]); | |
| 90 | + opt.style.path=pos; | |
| 91 | + console.log('opt.style', opt.style); | |
| 92 | + var polyline = new AMap.Polyline(opt.style); | |
| 93 | + //根据ID保存映射 | |
| 94 | + polylines[opt.id]=polyline; | |
| 95 | + if(opt.hide) | |
| 96 | + polyline.hide(); | |
| 95 | 97 | |
| 98 | + polyline.setMap(map); | |
| 99 | + | |
| 100 | + map.setCenter(pos[parseInt(pos.length / 2)]); | |
| 101 | + | |
| 102 | + }, | |
| 103 | + //根据id 显示polyline | |
| 104 | + refreshPolyline: function (opt) { | |
| 105 | + var idx = opt.idx; | |
| 106 | + for(var id in polylines){ | |
| 107 | + if(idx.indexOf(id) != -1) | |
| 108 | + polylines[id].show(); | |
| 109 | + else | |
| 110 | + polylines[id].hide(); | |
| 96 | 111 | } |
| 97 | - //下行 | |
| 98 | - if(route.down){ | |
| 99 | - $.each(route.down_gcj.split(','), function(){ | |
| 100 | - tempArray = this.split(' '); | |
| 101 | - downArr.push([tempArray[0], tempArray[1]]); | |
| 102 | - }); | |
| 103 | - var downLine = new AMap.Polyline(downLineOps); | |
| 104 | - //保存线条引用 | |
| 105 | - linePolyline.push(downLine); | |
| 106 | - downLine.setMap(map); | |
| 107 | - } | |
| 108 | - //实时路况下不显示 | |
| 109 | - if(traffVisible) | |
| 110 | - hideLinePolyline(); | |
| 111 | 112 | }, |
| 112 | 113 | drawRealGpsMarker: function(opts){ |
| 113 | - var gpsArray = opts.gpsList; | |
| 114 | + gpsArray = opts.gpsList; | |
| 115 | + var coord; | |
| 116 | + $.each(gpsArray, function(i, gps){ | |
| 117 | + | |
| 118 | + marker = realMarkers[gps.deviceId]; | |
| 119 | + if(marker && gps.timestamp == marker.gpsData.timestamp) | |
| 120 | + return; | |
| 121 | + else{ | |
| 122 | + //转换坐标 | |
| 123 | + transCoord(gps); | |
| 124 | + | |
| 125 | + if(marker) | |
| 126 | + moveMarker(marker, gps);//移动marker | |
| 127 | + else { | |
| 128 | + //创建marker | |
| 129 | + marker = createGDMarkerByGps(gps); | |
| 130 | + realMarkers[gps.deviceId] = marker | |
| 131 | + } | |
| 132 | + } | |
| 133 | + | |
| 134 | + /*coord = TransGPS.transformFromWGSToGCJ(gps.lat, gps.lon); | |
| 135 | + gps.gcj_lat = coord.lat; | |
| 136 | + gps.gcj_lon = coord.lng; | |
| 137 | + | |
| 138 | + marker = realMarkers[gps.deviceId]; | |
| 139 | + if(marker){ | |
| 140 | + if(gps.timestamp == marker.gpsData.timestamp) | |
| 141 | + return; | |
| 142 | + else | |
| 143 | + moveMarker(marker, gps);//移动marker | |
| 144 | + } | |
| 145 | + else{ | |
| 146 | + var marker = createGDMarkerByGps(gps); | |
| 147 | + realMarkers[gps.deviceId] = marker | |
| 148 | + }*/ | |
| 149 | + }); | |
| 150 | + | |
| 151 | + /*var gpsArray = opts.gpsList; | |
| 114 | 152 | var coord; |
| 115 | 153 | $.each(gpsArray, function(i, gps){ |
| 116 | 154 | if(opts.coordTransform){ |
| ... | ... | @@ -130,7 +168,16 @@ var gb_map_gaode = (function() { |
| 130 | 168 | var marker = createGDMarkerByGps(gps); |
| 131 | 169 | realMarkers[gps.deviceId] = marker |
| 132 | 170 | } |
| 133 | - }); | |
| 171 | + });*/ | |
| 172 | + }, | |
| 173 | + showGpsMarker: function (opt) { | |
| 174 | + var chs = opt.chs; | |
| 175 | + for(var device in realMarkers){ | |
| 176 | + if(chs[device]) | |
| 177 | + realMarkers[device].show(); | |
| 178 | + else | |
| 179 | + realMarkers[device].hide(); | |
| 180 | + } | |
| 134 | 181 | }, |
| 135 | 182 | goToMarker: function(opts){ |
| 136 | 183 | var deviceId = opts.deviceId |
| ... | ... | @@ -147,6 +194,12 @@ var gb_map_gaode = (function() { |
| 147 | 194 | } |
| 148 | 195 | }; |
| 149 | 196 | |
| 197 | + function transCoord(gps) { | |
| 198 | + var coord = TransGPS.transformFromWGSToGCJ(gps.lat, gps.lon); | |
| 199 | + gps.gcj_lat = coord.lat; | |
| 200 | + gps.gcj_lon = coord.lng; | |
| 201 | + } | |
| 202 | + | |
| 150 | 203 | function createGDMarkerByGps(gps){ |
| 151 | 204 | //根据编码长度 计算marker 宽度 |
| 152 | 205 | var w = gps.nbbm.length * 10; |
| ... | ... | @@ -156,7 +209,7 @@ var gb_map_gaode = (function() { |
| 156 | 209 | position: [gps.gcj_lon, gps.gcj_lat], |
| 157 | 210 | icon: new AMap.Icon({ |
| 158 | 211 | size: new AMap.Size(w, 25), //图标大小 |
| 159 | - image: iMap.createCarIcon(gps, w) | |
| 212 | + image: gb_map_imap.createCarIcon(gps, w) | |
| 160 | 213 | }), |
| 161 | 214 | offset: new AMap.Pixel(-35, -12) |
| 162 | 215 | }); |
| ... | ... | @@ -184,14 +237,14 @@ var gb_map_gaode = (function() { |
| 184 | 237 | var w = gps.nbbm.length * 10; |
| 185 | 238 | m.setIcon(new AMap.Icon({ |
| 186 | 239 | size: new AMap.Size(w, 25), |
| 187 | - image: iMap.createCarIcon(gps, w) | |
| 240 | + image: gb_map_imap.createCarIcon(gps, w) | |
| 188 | 241 | })); |
| 189 | 242 | |
| 190 | 243 | if(m.infoWindow.getIsOpen()) |
| 191 | 244 | openWindow(m); |
| 192 | 245 | } |
| 193 | 246 | |
| 194 | - //隐藏线路线条 | |
| 247 | +/* //隐藏线路线条 | |
| 195 | 248 | function hideLinePolyline(){ |
| 196 | 249 | if(!linePolyline || linePolyline.length == 0) |
| 197 | 250 | return; |
| ... | ... | @@ -199,9 +252,9 @@ var gb_map_gaode = (function() { |
| 199 | 252 | $.each(linePolyline, function(){ |
| 200 | 253 | this.setOptions({strokeOpacity: 0}); |
| 201 | 254 | }); |
| 202 | - } | |
| 255 | + }*/ | |
| 203 | 256 | |
| 204 | - //显示线路线条 | |
| 257 | +/* //显示线路线条 | |
| 205 | 258 | function showLinePolyline(){ |
| 206 | 259 | if(!linePolyline || linePolyline.length == 0) |
| 207 | 260 | return; |
| ... | ... | @@ -210,14 +263,16 @@ var gb_map_gaode = (function() { |
| 210 | 263 | $.each(linePolyline, function(){ |
| 211 | 264 | this.setOptions({strokeOpacity: 0.5}); |
| 212 | 265 | }); |
| 213 | - } | |
| 266 | + }*/ | |
| 214 | 267 | |
| 215 | 268 | function openWindow(marker){ |
| 216 | - marker.gpsData.fromNow = moment(marker.gpsData.timestamp).fromNow(); | |
| 217 | - /*var infoWindow = new AMap.InfoWindow({ | |
| 218 | - content: template('gps_info_win_temp', marker.gpsData) | |
| 219 | - });*/ | |
| 220 | - marker.infoWindow.setContent(template('gps_info_win_temp', marker.gpsData)); | |
| 269 | + var gps = marker.gpsData; | |
| 270 | + //线路名 | |
| 271 | + gps.lineName = gb_data_basic.lineCode2NameAll()[gps.lineId]; | |
| 272 | + //时间 | |
| 273 | + gps.dateStr = moment(gps.timestamp).format('YYYY-MM-DD HH:mm:ss'); | |
| 274 | +//{size: AMap.Size(290,255)} | |
| 275 | + marker.infoWindow.setContent(gb_map_overlay_mge.map_gps_win_temp(gps)); | |
| 221 | 276 | marker.infoWindow.open(map, marker.getPosition()); |
| 222 | 277 | } |
| 223 | 278 | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/js/map_overlay_manager.js
| ... | ... | @@ -8,6 +8,9 @@ var gb_map_overlay_mge = (function () { |
| 8 | 8 | }); |
| 9 | 9 | |
| 10 | 10 | var gpsRefresh = function (addArr, upArr, upDownChange) { |
| 11 | + //如果地图正在重绘,暂时不刷新GPS | |
| 12 | + if(reDrawing) | |
| 13 | + return; | |
| 11 | 14 | var all = addArr.concat(upArr).concat(upDownChange); |
| 12 | 15 | gpsRefreshAll(all); |
| 13 | 16 | |
| ... | ... | @@ -32,7 +35,7 @@ var gb_map_overlay_mge = (function () { |
| 32 | 35 | //上行 |
| 33 | 36 | gb_map_imap.call('drawLine', { |
| 34 | 37 | route: route, |
| 35 | - style: {strokeWeight:6, strokeColor: 'blue'}, | |
| 38 | + style: {strokeWeight:6, strokeColor: gb_map_config.getConfig().section.color.up}, | |
| 36 | 39 | id: lineCode+'_0', |
| 37 | 40 | upDown: 0, |
| 38 | 41 | hide: true |
| ... | ... | @@ -40,7 +43,7 @@ var gb_map_overlay_mge = (function () { |
| 40 | 43 | //下行 |
| 41 | 44 | gb_map_imap.call('drawLine', { |
| 42 | 45 | route: route, |
| 43 | - style: {strokeWeight:6, strokeColor: 'red'}, | |
| 46 | + style: {strokeWeight:6, strokeColor: gb_map_config.getConfig().section.color.down}, | |
| 44 | 47 | id: lineCode+'_1', |
| 45 | 48 | upDown: 1, |
| 46 | 49 | hide: true |
| ... | ... | @@ -59,7 +62,13 @@ var gb_map_overlay_mge = (function () { |
| 59 | 62 | gb_map_imap.call('refreshPolyline', {idx: gb_common.get_keys(idx)}); |
| 60 | 63 | }; |
| 61 | 64 | |
| 62 | - var init = function () { | |
| 65 | + | |
| 66 | + //是否正在重绘 | |
| 67 | + var reDrawing; | |
| 68 | + var reDraw = function () { | |
| 69 | + reDrawing = true; | |
| 70 | + | |
| 71 | + gb_map_imap.call('clearAll'); | |
| 63 | 72 | |
| 64 | 73 | drawAllSection(); |
| 65 | 74 | //初始绘制 |
| ... | ... | @@ -68,6 +77,12 @@ var gb_map_overlay_mge = (function () { |
| 68 | 77 | showOverlayByChecks(); |
| 69 | 78 | //显示路段 |
| 70 | 79 | showSection(gb_map_gps_tree.getChecked().filter(deviceFilter)); |
| 80 | + | |
| 81 | + reDrawing = false; | |
| 82 | + } | |
| 83 | + | |
| 84 | + var init = function () { | |
| 85 | + reDraw(); | |
| 71 | 86 | //注册GPS刷新事件 |
| 72 | 87 | gb_data_gps.registerCallback(gpsRefresh); |
| 73 | 88 | }; |
| ... | ... | @@ -97,6 +112,7 @@ var gb_map_overlay_mge = (function () { |
| 97 | 112 | _focus: _focus, |
| 98 | 113 | map_gps_win_temp: function (data) { |
| 99 | 114 | return temps['map-win-gps-detail-temp'](data); |
| 100 | - } | |
| 115 | + }, | |
| 116 | + reDraw: reDraw | |
| 101 | 117 | }; |
| 102 | 118 | })(); |
| 103 | 119 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/mapmonitor/real_monitor/js/map/platform/baidu.js