| | |
| | | import com.vci.corba.portal.data.*; |
| | | import com.vci.dto.RoleRightDTO; |
| | | import com.vci.dto.UIAuthorDTO; |
| | | import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; |
| | | import com.vci.model.PLDefination; |
| | | import com.vci.pagemodel.PLDefinationVO; |
| | | import com.vci.pagemodel.PLTabButtonVO; |
| | | import com.vci.pagemodel.PLUILayoutCloneVO; |
| | | import com.vci.pagemodel.RoleRightVO; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | |
| | | import lombok.NoArgsConstructor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.swing.*; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | */ |
| | | @Resource |
| | | private SmRoleQueryServiceI smRoleQueryServiceI; |
| | | |
| | | /*** |
| | | * 是否是管理员 |
| | | */ |
| | | @Autowired |
| | | RightControlUtil rightControlUtil; |
| | | /** |
| | | * 业务类型 |
| | | */ |
| | |
| | | @Override |
| | | public int compare(PLUILayout o1, PLUILayout o2) { |
| | | return o1.plCode.compareTo(o2.plCode); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 排序比较器 |
| | | */ |
| | | private Comparator<PLDefinationVO> pageDefinationComparator = new Comparator<PLDefinationVO>() { |
| | | @Override |
| | | public int compare(PLDefinationVO o1, PLDefinationVO o2) { |
| | | return new Integer(o1.getSeq()).compareTo(new Integer(o2.getSeq())); |
| | | } |
| | | }; |
| | | |
| | |
| | | * 根据上下文ID和区域类型,按顺序获取当前区域的tab页 |
| | | */ |
| | | @Override |
| | | public List<PLTabPage> getTabByContextIdAndType(String contextId, int areaType) throws PLException { |
| | | public DataGrid getTabByContextIdAndType(String contextId, int areaType) throws PLException { |
| | | VciBaseUtil.alertNotNull(contextId,"上下文主键",areaType,"区域类型"); |
| | | PLTabPage[] plTabPages = platformClientUtil.getUIService().getTabPagesByContextIdAndType(contextId, (short) areaType); |
| | | return Arrays.asList(plTabPages); |
| | | DataGrid dataGrid = new DataGrid(); |
| | | dataGrid.setTotal(plTabPages.length); |
| | | dataGrid.setData(Arrays.asList(plTabPages)); |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 查询页面设计定义 |
| | | * @param plPageContextOId |
| | | * @param pageContextOId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PLPageDefination> getPLPageDefinations(String plPageContextOId) { |
| | | public DataGrid getPLPageDefinations(String pageContextOId) throws PLException { |
| | | DataGrid dataGrid = new DataGrid(); |
| | | if(Func.isBlank(pageContextOId)) return dataGrid; |
| | | PLPageDefination[] plPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(pageContextOId); |
| | | if(Func.isEmpty(plPageDefinations)){ |
| | | return dataGrid; |
| | | } |
| | | //DO2VO |
| | | List<PLDefinationVO> plDefinationVOS = this.pageDefinations2PLDefinationVO(Arrays.asList(plPageDefinations)); |
| | | dataGrid.setTotal(plDefinationVOS.size()); |
| | | Collections.sort(plDefinationVOS, Comparator.comparing(PLDefinationVO::getSeq)); |
| | | //Arrays.sort(plDefinationVOS, pageDefinationComparator); |
| | | dataGrid.setData(plDefinationVOS); |
| | | return dataGrid; |
| | | } |
| | | |
| | | return null; |
| | | /** |
| | | * 页面定义的DO2VO对象 |
| | | * @param plPageDefinations |
| | | * @return |
| | | */ |
| | | private List<PLDefinationVO> pageDefinations2PLDefinationVO(List<PLPageDefination> plPageDefinations){ |
| | | List<PLDefinationVO> plDefinationVOList = new ArrayList<>(); |
| | | plPageDefinations.stream().forEach(item->{ |
| | | try { |
| | | PLDefinationVO plDefinationVO = new PLDefinationVO(); |
| | | PLDefination plDefination = UITools.getPLDefination(item.plDefination); |
| | | BeanUtil.copy(plDefination,plDefinationVO); |
| | | plDefinationVOList.add(plDefinationVO); |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | logger.error(e.getMessage()); |
| | | throw new VciBaseException("页面定义DO对象转VO对象时出现错误,原因:"+e.getMessage()); |
| | | } |
| | | }); |
| | | return plDefinationVOList; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean updatePageDefination(PLDefinationVO pdVO) throws Throwable { |
| | | /*PLPageDefination pd = getPageDefination(); |
| | | |
| | | PLDefination d = UITools.getPLDefination(pd.plDefination); |
| | | VciBaseUtil.alertNotNull(pdVO,"页面定义对象",pdVO.getSeq(),"编号",pdVO.getName(),"名称"); |
| | | PLPageDefination pd = new PLPageDefination(); |
| | | PLDefination d = new PLDefination(); |
| | | BeanUtil.copy(pdVO,d); |
| | | |
| | | //不能为空属性检查 |
| | | if(!this.baseInfoIsOk(pd,true)){ |
| | | return false; |
| | | } |
| | | setUIValueToObject(pd, d); |
| | | pd.name = pdVO.getName().trim(); |
| | | pd.seq = Short.valueOf(pdVO.getSeq().trim()); |
| | | pd.desc = pdVO.getDescription(); |
| | | pd.plType = Short.parseShort(pdVO.getTemplateType()); |
| | | |
| | | d.setName(pdVO.getName().trim()); |
| | | d.setUiParser(pdVO.getUiParser().trim()); |
| | | d.setExtAttr(pdVO.getExtAttr().trim()); |
| | | d.setTemplateType(pdVO.getTemplateType()); |
| | | |
| | | this.newPLDefinationIsOk(pdVO, true); |
| | | |
| | |
| | | break; |
| | | } |
| | | |
| | | d = comptPanel.getNewPLDefination(d); |
| | | d = setEventDataToPLDefination(d,pdVO); |
| | | pd.plDefination = UITools.getPLDefinationText(d);*/ |
| | | pd.plDefination = UITools.getPLDefinationText(d); |
| | | |
| | | boolean res = true;//platformClientUtil.getUIService().updatePLPageDefination(pd); |
| | | return platformClientUtil.getUIService().updatePLPageDefination(pd); |
| | | } |
| | | |
| | | /** |
| | | * 删除页面定义 |
| | | * @param oids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean delPageDefination(String[] oids) throws PLException { |
| | | VciBaseUtil.alertNotNull(oids,"删除的页面定义主键"); |
| | | boolean res = platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 获取页签区域按钮配置信息 |
| | | * @param pageDefinationOid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PLTabButtonVO> getTabButton(String pageDefinationOid) { |
| | | VciBaseUtil.alertNotNull(pageDefinationOid,"页面定义主键"); |
| | | List<PLTabButton> buttonList = new ArrayList<>(); |
| | | try { |
| | | PLTabButton[] plTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(pageDefinationOid); |
| | | buttonList = Arrays.asList(plTabButtons); |
| | | return this.tabButton2TabButtonVOS(buttonList); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("加载页签区域按钮配置信息异常:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 多个按钮配置DO对象转多个VO对象 |
| | | * @param listDO |
| | | * @return |
| | | */ |
| | | private List<PLTabButtonVO> tabButton2TabButtonVOS(List<PLTabButton> listDO){ |
| | | List<PLTabButtonVO> plTabButtonVOList = new ArrayList<PLTabButtonVO>(); |
| | | if(Func.isEmpty(listDO)){ |
| | | return plTabButtonVOList; |
| | | } |
| | | listDO.stream().forEach(item->{ |
| | | try { |
| | | PLTabButtonVO plTabButtonVO = this.tabButton2TabButtonVO(item); |
| | | plTabButtonVOList.add(plTabButtonVO); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String errorLog = "按钮配置DO TO VO时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorLog); |
| | | throw new VciBaseException(errorLog); |
| | | } |
| | | |
| | | }); |
| | | return plTabButtonVOList; |
| | | } |
| | | |
| | | /** |
| | | * 按钮配置DO对象转VO对象 |
| | | * @param tabButtonDO |
| | | * @return |
| | | */ |
| | | private PLTabButtonVO tabButton2TabButtonVO(PLTabButton tabButtonDO) throws PLException { |
| | | PLTabButtonVO plTabButtonVO = new PLTabButtonVO(); |
| | | if(Func.isEmpty(tabButtonDO) && Func.isBlank(tabButtonDO.plOId)){ |
| | | return plTabButtonVO; |
| | | } |
| | | plTabButtonVO.setOId(tabButtonDO.plOId); |
| | | plTabButtonVO.setTableOId(tabButtonDO.plTableOId); |
| | | plTabButtonVO.setPageOId(tabButtonDO.plPageOId); |
| | | plTabButtonVO.setActionOId(tabButtonDO.plActionOId); |
| | | plTabButtonVO.setLabel(tabButtonDO.plLabel); |
| | | plTabButtonVO.setAreaType(tabButtonDO.plAreaType); |
| | | plTabButtonVO.setDesc(tabButtonDO.plDesc); |
| | | plTabButtonVO.setSeq(tabButtonDO.plSeq); |
| | | plTabButtonVO.setCreateUser(tabButtonDO.plCreateUser); |
| | | plTabButtonVO.setCreateTime(tabButtonDO.plCreateTime); |
| | | plTabButtonVO.setModifyUser(tabButtonDO.plModifyUser); |
| | | plTabButtonVO.setModifyTime(tabButtonDO.plModifyTime); |
| | | plTabButtonVO.setLicensOrs(tabButtonDO.plLicensOrs); |
| | | plTabButtonVO.setParentOid(tabButtonDO.plParentOid); |
| | | plTabButtonVO.setDisplayMode(tabButtonDO.displayMode); |
| | | plTabButtonVO.setIconPath(tabButtonDO.iconPath); |
| | | plTabButtonVO.setAuthorization(tabButtonDO.authorization); |
| | | plTabButtonVO.setShow(tabButtonDO.show); |
| | | //参数信息回填 |
| | | PLCommandParameter[] parameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(tabButtonDO.plOId); |
| | | if(Func.isNotEmpty(parameters)){ |
| | | LinkedHashMap<String, String> parameterMap = (LinkedHashMap<String, String>)Arrays.stream(parameters).collect(Collectors.toMap(parm -> parm.plKey, parm -> parm.plValue)); |
| | | plTabButtonVO.setButtonParams(parameterMap); |
| | | } |
| | | return plTabButtonVO; |
| | | } |
| | | |
| | | /** |
| | | * 按钮配置VO对象转DO对象 |
| | | * @param tabButtonVO |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | private PLTabButton tabButtonVO2TabButton(PLTabButton plTabButton,PLTabButtonVO tabButtonVO) { |
| | | plTabButton.plOId = tabButtonVO.getOId(); |
| | | plTabButton.plTableOId = tabButtonVO.getTableOId(); |
| | | plTabButton.plPageOId = tabButtonVO.getPageOId(); |
| | | plTabButton.plActionOId = tabButtonVO.getActionOId(); |
| | | plTabButton.plLabel = tabButtonVO.getLabel(); |
| | | plTabButton.plAreaType = tabButtonVO.getAreaType(); |
| | | plTabButton.plDesc = tabButtonVO.getDesc(); |
| | | plTabButton.plSeq = tabButtonVO.getSeq(); |
| | | plTabButton.plCreateUser = tabButtonVO.getCreateUser(); |
| | | plTabButton.plCreateTime = tabButtonVO.getCreateTime(); |
| | | plTabButton.plModifyUser = tabButtonVO.getModifyUser(); |
| | | plTabButton.plModifyTime = tabButtonVO.getModifyTime(); |
| | | plTabButton.plLicensOrs = tabButtonVO.getLicensOrs(); |
| | | plTabButton.plParentOid = tabButtonVO.getParentOid(); |
| | | plTabButton.displayMode = tabButtonVO.getDisplayMode(); |
| | | plTabButton.iconPath = tabButtonVO.getIconPath(); |
| | | plTabButton.authorization = tabButtonVO.getAuthorization(); |
| | | plTabButton.show = tabButtonVO.getShow(); |
| | | return plTabButton; |
| | | } |
| | | |
| | | /** |
| | | * 添加按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult addTapButton(PLTabButtonVO tabButtonVO) { |
| | | boolean res = this.saveOrUpdateTapButton(tabButtonVO, true); |
| | | return res ? BaseResult.success("按钮配置添加成功!"):BaseResult.success("按钮配置添加失败!"); |
| | | } |
| | | |
| | | /** |
| | | * 修改按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult updateTapButton(PLTabButtonVO tabButtonVO) { |
| | | boolean res = this.saveOrUpdateTapButton(tabButtonVO, false); |
| | | return res ? BaseResult.success("按钮配置修改成功!"):BaseResult.success("按钮配置修改失败!"); |
| | | } |
| | | |
| | | /** |
| | | * 保存或修改按钮配置信息 |
| | | * @param tabButtonVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateTapButton(PLTabButtonVO tabButtonVO,boolean isAdd){ |
| | | VciBaseUtil.alertNotNull(tabButtonVO,"按钮配置对象",tabButtonVO.getLabel(),"参数名称"); |
| | | //检查当前添加的列表是否重复,但是这儿只支持单条数据保存,所有当前列表判重可以前端来做 |
| | | //String btnParamValidate = this.geCheckRes(); |
| | | |
| | | if (tabButtonVO.getSeq() < 1 || tabButtonVO.getSeq() > 63) { |
| | | throw new VciBaseException("按序号超出范围,请修改,按钮【编号】只能在【1-63】范围内。"); |
| | | } |
| | | //当前登录用户的信息 |
| | | SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | //VO2DO |
| | | PLTabButton plTabButton = this.tabButtonVO2TabButton(new PLTabButton(), tabButtonVO); |
| | | if(isAdd) { |
| | | //如果是增加操作,直接创建PLTabButton对象 |
| | | plTabButton.plOId = ObjectUtility.getNewObjectID36(); |
| | | plTabButton.plCreateUser = sessionInfo.getUserId(); |
| | | plTabButton.plModifyUser = sessionInfo.getUserId(); |
| | | } else { |
| | | //修改操作 |
| | | plTabButton.plModifyUser = sessionInfo.getUserId(); |
| | | } |
| | | |
| | | try { |
| | | if(isAdd){ |
| | | boolean success = platformClientUtil.getUIService().savePLTabButton(plTabButton); |
| | | if(success == false) { |
| | | throw new VciBaseException("编号重复,编号已经在当前页签下存在!"); |
| | | } |
| | | } else if(!isAdd){ |
| | | platformClientUtil.getUIService().updatePLTabButton(plTabButton); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | String errorLog = "保存按钮信息时发生异常:" + e.getMessage(); |
| | | logger.error(errorLog); |
| | | throw new VciBaseException(errorLog); |
| | | } |
| | | //复用以前的代码,对于参数一条一条删除,一条一条创建 |
| | | //数据量及并发较少,暂时这么处理没有什么问题 |
| | | if(!isAdd) { |
| | | try { |
| | | platformClientUtil.getUIService().deletePLCommandParameterByTabButtonId(plTabButton.plOId); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | LinkedHashMap<String, String> buttonParams = tabButtonVO.getButtonParams(); |
| | | if(!buttonParams.isEmpty()) { |
| | | Iterator<Map.Entry<String, String>> iterator = buttonParams.entrySet().iterator(); |
| | | while(iterator.hasNext()){ |
| | | Map.Entry<String, String> next = iterator.next(); |
| | | if(StringUtils.isEmpty(next.getKey()) || StringUtils.isEmpty(next.getValue())){ |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if(!buttonParams.isEmpty()){ |
| | | Iterator<Map.Entry<String, String>> kvItor = buttonParams.entrySet().iterator(); |
| | | while(kvItor.hasNext()){ |
| | | Map.Entry<String, String> next = kvItor.next(); |
| | | PLCommandParameter plCommandParameter = new PLCommandParameter(); |
| | | plCommandParameter.plOId = ObjectUtility.getNewObjectID36(); |
| | | plCommandParameter.plCommandOId = plTabButton.plOId; |
| | | plCommandParameter.plKey = next.getKey(); |
| | | plCommandParameter.plValue = next.getValue(); |
| | | plCommandParameter.plCreateUser = sessionInfo.getUserId(); |
| | | plCommandParameter.plModifyUser = sessionInfo.getUserId(); |
| | | try { |
| | | platformClientUtil.getUIService().savePLCommandParameter(plCommandParameter); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("保存按钮信息时发生异常:"+ e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理配置的event事件 |
| | |
| | | } else { |
| | | res = true; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 删除页面定义 |
| | | * @param oids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean delPageDefination(String[] oids) throws PLException { |
| | | VciBaseUtil.alertNotNull(oids,"删除的页面定义主键"); |
| | | boolean res = platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids); |
| | | return res; |
| | | } |
| | | |
| | |
| | | return treeList; |
| | | } |
| | | |
| | | /*** |
| | | * UI授权 |
| | | * @param uiAuthorDTO |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public boolean authorizedUI(UIAuthorDTO uiAuthorDTO) throws Exception { |
| | | boolean res=false; |
| | |
| | | treeQueryObject.setConditionMap(conditionMap); |
| | | List<Tree> treeList=this.getUIAuthor(treeQueryObject); |
| | | HashMap<String,Tree> allTreeMap=new HashMap<>(); |
| | | Map<String,RoleRightVO> roleRightVOMap=new HashMap<>(); |
| | | if(!CollectionUtil.isEmpty(treeList)){ |
| | | if(StringUtils.isNotBlank(uiAuthorDTO.getRoleId())){ |
| | | String userName= WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | RoleRightInfo[] rightInfos= platformClientUtil.getFrameworkService().getRoleRightList(uiAuthorDTO.getRoleId(),userName); |
| | | List<RoleRightVO> roleRightVOList=roleRightDOO2VOS(Arrays.asList(rightInfos)); |
| | | roleRightVOMap=roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO)); |
| | | } |
| | | convertTreeDOO2Map(treeList,allTreeMap); |
| | | List<RoleRightDTO> roleRightDTOList=new ArrayList<>(); |
| | | List<Tree> selectTreeList= uiAuthorDTO.getSelectTreeList(); |
| | | getRoleRightDTOS(uiAuthorDTO.getRoleId(),selectTreeList,allTreeMap,roleRightDTOList); |
| | | getSelectedRoleRightObjs(uiAuthorDTO.getRoleId(),selectTreeList,allTreeMap,roleRightDTOList); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | private void getRoleRightDTOS(String roleOid,List<Tree> selectTreeList,HashMap<String,Tree> allTreeMap, List<RoleRightDTO> roleRightDTOList){ |
| | | /** |
| | | * |
| | | * @param roleOid |
| | | * @param selectTreeList |
| | | * @param allTreeMap |
| | | * @param roleRightDTOList |
| | | */ |
| | | private void getSelectedRoleRightObjs(String roleOid,List<Tree> selectTreeList,HashMap<String,Tree> allTreeMap, List<RoleRightDTO> roleRightDTOList){ |
| | | Date date=new Date(); |
| | | Map<String,RoleRightDTO> roleRightDTOMap=new HashMap<>(); |
| | | selectTreeList.stream().forEach(tree -> { |
| | | RoleRightDTO roleRightDTO=new RoleRightDTO(); |
| | | String id=ObjectUtility.getNewObjectID36(); |
| | | Object data= tree.getData(); |
| | | |
| | | if (data instanceof BizType) {//业务类型 |
| | | BizType bizType=(BizType)data; |
| | | roleRightDTO.setId(id);//主键 |
| | | roleRightDTO.setCreateUser(null);//创建者 |
| | | roleRightDTO.setCreateTime(null);//创建时间 |
| | | roleRightDTO.setModifyUser(null);//修改者 |
| | | roleRightDTO.setModifyTime(null);//修改时间 |
| | | roleRightDTO.setRoleId(roleOid);//角色ID |
| | | roleRightDTO.setRightValue(1);// 权限值 |
| | | roleRightDTO.setRightType((short) -1);//权限类型 权限类型,超级管理员给管理员授权为1,管理员给普通用户授权为2 |
| | | roleRightDTO.setFuncId(null); |
| | | roleRightDTO.setLicensor(null); |
| | | }else if (data instanceof PLUILayout){//UI |
| | | |
| | | }else if (data instanceof PLTabPage) {//UI上下文 |
| | | |
| | | |
| | | }else if (data instanceof PLPageDefination) {// |
| | | |
| | | |
| | | if(data instanceof String){ |
| | | getRightValue(roleOid,tree,allTreeMap,false,roleRightDTOMap);//向下获取所有模块的权限值 |
| | | }else if (!(data instanceof PLTabButton)) {//业务类型 |
| | | getRightValue(roleOid,tree,allTreeMap,true,roleRightDTOMap);//向上处理 |
| | | getRightValue(roleOid,tree,allTreeMap,false,roleRightDTOMap);//向下处理(包含当前节点) |
| | | }else if (data instanceof PLTabButton) {//按钮 |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | } |
| | | /** |
| | | * 获取权限 |
| | | * @param isUp 是否是向上获取,如果是向上获取,传进来的必然是模块节点,且上级模块必然是没有选中 |
| | | */ |
| | | private void getRightValue(String roleId,Tree node,HashMap<String,Tree> allTreeMap,boolean isUp,Map<String,RoleRightDTO> rightMap){ |
| | | SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | String currentUserName = sessionInfo.getUserId(); |
| | | boolean isDeveloper= rightControlUtil.isDeveloper(currentUserName); |
| | | String parentOid=node.getParentId(); |
| | | if(allTreeMap.containsKey(parentOid)){ |
| | | String id=ObjectUtility.getNewObjectID36(); |
| | | Tree parentNode =allTreeMap.get(parentOid); |
| | | Object parentData= parentNode.getData(); |
| | | if(isUp) {//向上获取,存储每个上级模块的权限值 |
| | | while (!"root".equals(parentNode.getData())){ |
| | | String funcId = ""; |
| | | if (parentData instanceof BizType) { |
| | | BizType bizType = (BizType) parentData; |
| | | funcId = bizType.name; |
| | | } else if (parentData instanceof PLUILayout) { |
| | | PLUILayout context = (PLUILayout)parentData; |
| | | funcId = context.plOId; |
| | | } else if (parentData instanceof PLTabPage) { |
| | | PLTabPage tab = (PLTabPage) parentData; |
| | | funcId = tab.plOId; |
| | | } else if (parentData instanceof PLPageDefination){ |
| | | PLPageDefination pageDef = (PLPageDefination) parentData; |
| | | funcId = pageDef.plOId; |
| | | } else if (parentData instanceof PLTabButton) { |
| | | PLTabButton but = (PLTabButton)parentData; |
| | | funcId = but.plOId; |
| | | } |
| | | RoleRightDTO roleRightDTO = new RoleRightDTO(); |
| | | roleRightDTO.setId(id);//主键 |
| | | roleRightDTO.setFuncId(funcId); |
| | | if(isDeveloper) { |
| | | roleRightDTO.setRightType((short) 1);//权限类型 权限类型,超级管理员给管理员授权为1,管理员给普通用户授权为2 |
| | | }else{ |
| | | roleRightDTO.setRightType((short) 2); |
| | | } |
| | | roleRightDTO.setRightValue(1);// 权限值,没有操作的模块权限值存储为0 |
| | | roleRightDTO.setRoleId(roleId);//角色ID |
| | | roleRightDTO.setCreateUser(currentUserName);//创建者 |
| | | roleRightDTO.setCreateTime(new Date());//创建时间 |
| | | roleRightDTO.setModifyUser(currentUserName);//修改者 |
| | | roleRightDTO.setModifyTime(new Date());//修改时间 |
| | | roleRightDTO.setLicensor(""); |
| | | if(!rightMap.containsKey(funcId)){ |
| | | rightMap.put(funcId, roleRightDTO); |
| | | } |
| | | } |
| | | }else{ |
| | | String funcId = ""; |
| | | if(parentData instanceof String){ |
| | | funcId = (String)parentData; |
| | | } else if (parentData instanceof BizType) { |
| | | BizType bizType = (BizType)parentData; |
| | | funcId = bizType.name; |
| | | } else if (parentData instanceof PLUILayout) { |
| | | PLUILayout context = (PLUILayout)parentData; |
| | | funcId = context.plOId; |
| | | } else if (parentData instanceof PLTabPage) { |
| | | PLTabPage tab = (PLTabPage) parentData; |
| | | funcId = tab.plOId; |
| | | } else if (parentData instanceof PLPageDefination){ |
| | | PLPageDefination pageDef = (PLPageDefination) parentData; |
| | | funcId = pageDef.plOId; |
| | | } else if (parentData instanceof PLTabButton) { |
| | | PLTabButton but = (PLTabButton)parentData; |
| | | funcId = but.plOId; |
| | | } |
| | | if(!(parentData instanceof PLPageDefination)) {//子节点不是操作 |
| | | if(!rightMap.containsKey(funcId)&&!funcId.equals("root")){ |
| | | RoleRightDTO roleRightDTO = new RoleRightDTO(); |
| | | roleRightDTO.setFuncId(funcId); |
| | | if(isDeveloper) { |
| | | roleRightDTO.setRightType((short) 1);//权限类型 权限类型,超级管理员给管理员授权为1,管理员给普通用户授权为2 |
| | | }else{ |
| | | roleRightDTO.setRightType((short) 2); |
| | | } |
| | | roleRightDTO.setRightValue(0);//没有操作的模块权限值存储为0 |
| | | roleRightDTO.setRoleId(roleId); |
| | | roleRightDTO.setCreateUser(currentUserName); |
| | | roleRightDTO.setCreateTime(new Date()); |
| | | roleRightDTO.setModifyUser(currentUserName); |
| | | roleRightDTO.setModifyTime(new Date()); |
| | | roleRightDTO.setLicensor(""); |
| | | rightMap.put(funcId, roleRightDTO); |
| | | } |
| | | for(int i = 0;i < parentNode.getChildren().size();i++){ |
| | | //对每个子向下递归遍历 |
| | | getRightValue(roleId,parentNode.getChildren().get(i),allTreeMap,false,rightMap); |
| | | } |
| | | }else { |
| | | if(!rightMap.containsKey(funcId)){ |
| | | RoleRightDTO roleRightDTO = new RoleRightDTO(); |
| | | roleRightDTO.setFuncId(funcId); |
| | | roleRightDTO.setRightType((short)2); // 设置UI权限 |
| | | roleRightDTO.setRightValue(countRightValue(parentNode,true));//没有操作的模块权限值存储为0 |
| | | roleRightDTO.setRoleId(roleId); |
| | | |
| | | roleRightDTO.setCreateUser(currentUserName); |
| | | roleRightDTO.setCreateTime(new Date()); |
| | | roleRightDTO.setModifyUser(currentUserName); |
| | | roleRightDTO.setModifyTime(new Date()); |
| | | roleRightDTO.setLicensor(""); |
| | | rightMap.put(funcId, roleRightDTO); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 传入直接挂接操作的模块的节点,计算该节点的权限值 |
| | | * @param node 模块节点 |
| | | * @param isAll 是否子级全部选中 |
| | | * @return |
| | | */ |
| | | private long countRightValue(Tree node,boolean isAll){ |
| | | long value = 0; |
| | | for(int i = 0;i < node.getChildren().size();i++){ |
| | | Tree childNode = (Tree)node.getChildren().get(i); |
| | | if(isAll && node.getData() instanceof PLTabButton ){ |
| | | PLTabButton obj = (PLTabButton)node.getData(); |
| | | value += (long)Math.pow(2, obj.plSeq);//累计加上各个操作的权限值 |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * UI角色对象转换 |
| | | * @param infos |