| | |
| | | import com.vci.corba.omd.btm.BizType; |
| | | import com.vci.corba.portal.PortalService; |
| | | 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.pagemodel.OsBtmTypeVO; |
| | | import com.vci.pagemodel.PLUILayoutCloneVO; |
| | | import com.vci.pagemodel.RoleRightVO; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.starter.web.pagemodel.Tree; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.VciDateUtil; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | |
| | | /** |
| | | * ton通过业务类型和名称查询 |
| | | * @param btemName |
| | | * @param code |
| | | * @param context |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | public List<PLUILayout> getUIContextDataByBtName(String btemName,String code) throws PLException { |
| | | public List<PLUILayout> getUIContextDataByBtName(String btemName,String context) throws PLException { |
| | | VciBaseUtil.alertNotNull(btemName,"业务类型"); |
| | | List<PLUILayout> pluiLayoutList=new ArrayList<>(); |
| | | PLUILayout[] pluiLayouts= platformClientUtil.getUIService().getPLUILayoutEntityByTypeAndCode(btemName,code); |
| | | if(pluiLayouts!=null&&pluiLayouts.length>0){ |
| | | pluiLayoutList= Stream.of(pluiLayouts).collect(Collectors.toList()); |
| | | List<String> contextList= VciBaseUtil.str2List(context); |
| | | if(StringUtils.isNotBlank(context)){ |
| | | contextList=VciBaseUtil.str2List(context); |
| | | }else{ |
| | | contextList.add(""); |
| | | } |
| | | contextList.stream().forEach(code->{ |
| | | PLUILayout[] pluiLayouts= new PLUILayout[0]; |
| | | try { |
| | | pluiLayouts = platformClientUtil.getUIService().getPLUILayoutEntityByTypeAndCode(btemName,code); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(pluiLayouts!=null&&pluiLayouts.length>0) { |
| | | pluiLayoutList.addAll(Arrays.stream(pluiLayouts).collect(Collectors.toList())); |
| | | } |
| | | }); |
| | | |
| | | return pluiLayoutList; |
| | | } |
| | | |
| | |
| | | bizTypeTree.setParentId(rootNode.getOid()); |
| | | bizTypeTree.setParentName(rootNode.getText()); |
| | | bizTypeTree.setShowCheckbox(true); |
| | | bizTypeTree.setParentBtmName(bizTypes[i].name); |
| | | childList.add(bizTypeTree); |
| | | List<PLUILayout>contextList=getUIContextDataByBtName(bizTypes[i].name,context); |
| | | List<Tree> btmChildList=new ArrayList<>(); |
| | | btmChildList.add(bizTypeTree); |
| | | setChildNode(btmChildList,contextList,roleRightVOMap,showCheckBox); |
| | | if(roleRightVOMap.containsKey(bizTypes[i].oid)){ |
| | | List<PLUILayout>contextList=getUIContextDataByBtName(bizTypes[i].name,context); |
| | | List<Tree> btmChildList=new ArrayList<>(); |
| | | btmChildList.add(bizTypeTree); |
| | | setChildNode(btmChildList,contextList,roleRightVOMap,showCheckBox); |
| | | } |
| | | } |
| | | rootNode.setChildren(childList); |
| | | treeList.add(rootNode); |
| | | return treeList; |
| | | } |
| | | |
| | | @Override |
| | | public boolean authorizedUI(UIAuthorDTO uiAuthorDTO) throws Exception { |
| | | boolean res=false; |
| | | if(uiAuthorDTO==null||CollectionUtil.isEmpty(uiAuthorDTO.getSelectTreeList())){ |
| | | throw new VciBaseException("请选择节点进行授权!"); |
| | | } |
| | | BaseQueryObject treeQueryObject=new BaseQueryObject(); |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("roleId",uiAuthorDTO.getRoleId()); |
| | | conditionMap.put("type",uiAuthorDTO.getType()); |
| | | conditionMap.put("context",uiAuthorDTO.getContext()); |
| | | conditionMap.put("showCheckBox","true"); |
| | | treeQueryObject.setConditionMap(conditionMap); |
| | | List<Tree> treeList=this.getUIAuthor(treeQueryObject); |
| | | HashMap<String,Tree> allTreeMap=new HashMap<>(); |
| | | if(!CollectionUtil.isEmpty(treeList)){ |
| | | convertTreeDOO2Map(treeList,allTreeMap); |
| | | List<RoleRightDTO> roleRightDTOList=new ArrayList<>(); |
| | | List<Tree> selectTreeList= uiAuthorDTO.getSelectTreeList(); |
| | | getRoleRightDTOS(uiAuthorDTO.getRoleId(),selectTreeList,allTreeMap,roleRightDTOList); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | private void getRoleRightDTOS(String roleOid,List<Tree> selectTreeList,HashMap<String,Tree> allTreeMap, List<RoleRightDTO> roleRightDTOList){ |
| | | 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) {// |
| | | |
| | | |
| | | }else if (data instanceof PLTabButton) {//按钮 |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param treeList 树节点 |
| | | * @param allTreeMap,所有的节点 |
| | | */ |
| | | private void convertTreeDOO2Map(List<Tree> treeList,Map<String,Tree> allTreeMap){ |
| | | Optional.ofNullable(treeList).orElseGet(()->new ArrayList<Tree>()).stream().forEach(tree -> { |
| | | List<Tree> childTreeList= tree.getChildren(); |
| | | allTreeMap.put(tree.getOid(),tree); |
| | | if(!CollectionUtil.isEmpty(childTreeList)){ |
| | | convertTreeDOO2Map(childTreeList,allTreeMap); |
| | | } |
| | | }); |
| | | } |
| | | private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList,Map<String,RoleRightVO> roleRightVOMap,boolean isShowCheckBox){ |
| | | Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<Tree>()).stream().forEach(pTree -> { |
| | | Object funcObj= pTree.getData(); |
| | |
| | | contextList.stream().forEach(context->{ |
| | | Tree childTree=new Tree(context.plOId,context.plName+"("+context.plCode+")",context); |
| | | childTree.setParentName(pTree.getText()); |
| | | childTree.setParentBtmName(pTree.getParentBtmName()); |
| | | childTree.setParentId(pTree.getOid()); |
| | | childTree.setLevel(pTree.getLevel()+1); |
| | | childTree.setShowCheckbox(isShowCheckBox); |
| | |
| | | Tree childTree=new Tree(plTabPage.plOId,plTabPage.plName,plTabPage); |
| | | childTree.setParentName(pTree.getText()); |
| | | childTree.setParentId(pTree.getOid()); |
| | | childTree.setParentBtmName(pTree.getParentBtmName()); |
| | | childTree.setLevel(pTree.getLevel()+1); |
| | | childTree.setShowCheckbox(isShowCheckBox); |
| | | chiledTreeList.add(childTree); |
| | |
| | | Tree childTree=new Tree(plPageDefination.plOId,plPageDefination.name,plPageDefination); |
| | | childTree.setParentName(pTree.getText()); |
| | | childTree.setParentId(pTree.getOid()); |
| | | childTree.setParentBtmName(pTree.getParentBtmName()); |
| | | childTree.setLevel(pTree.getLevel()+1); |
| | | childTree.setShowCheckbox(isShowCheckBox); |
| | | chiledTreeList.add(childTree); |
| | |
| | | Tree childTree=new Tree(plTabButton.plOId,plTabButton.plLabel,plTabButton); |
| | | childTree.setParentName(pTree.getText()); |
| | | childTree.setParentId(pTree.getOid()); |
| | | childTree.setParentBtmName(pTree.getParentBtmName()); |
| | | childTree.setLevel(pTree.getLevel()+1); |
| | | childTree.setShowCheckbox(isShowCheckBox); |
| | | childTree.setLeaf(true); |
| | |
| | | } |
| | | |
| | | }else if (funcObj instanceof PLTabButton) {//按钮 |
| | | String id = ((PLTabButton) funcObj).plTableOId; |
| | | PLTabButton plTabButton= (PLTabButton) funcObj; |
| | | String id =plTabButton.plTableOId; |
| | | if(roleRightVOMap.containsKey(id)){ |
| | | pTree.setChecked(true); |
| | | RoleRightVO roleRightVO = roleRightVOMap.get(id); |
| | | Long rightValue = roleRightVO.getRightValue(); |
| | | int nodeValue = plTabButton.plSeq; |
| | | if (nodeValue >= 0 && nodeValue <= 63) { |
| | | long preValue = (rightValue >> nodeValue) & 1; |
| | | if (preValue == 1) { |
| | | pTree.setChecked(true); |
| | | } |
| | | } |
| | | }else{ |
| | | pTree.setChecked(false); |
| | | } |