From 2a06a2a8aed92fd2eb4b4570b79f304a1c0caf6d Mon Sep 17 00:00:00 2001 From: yuxc <yuxc@vci-tech.com> Date: 星期四, 12 九月 2024 09:39:37 +0800 Subject: [PATCH] 1、Action树查询接口增加id。 2、增加角色列表接口 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java | 891 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 861 insertions(+), 30 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java index b3595cf..408a5c2 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java @@ -1,22 +1,29 @@ package com.vci.web.service.impl; -import com.vci.client.mw.ClientContextVariable; -import com.vci.common.qt.object.QTConstants; import com.vci.common.utility.ObjectUtility; import com.vci.corba.common.PLException; +import com.vci.corba.framework.data.RoleRightInfo; +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.model.PLDefination; -import com.vci.pagemodel.PLDefinationVO; -import com.vci.pagemodel.PLUILayoutCloneVO; +import com.vci.pagemodel.*; import com.vci.starter.web.exception.VciBaseException; +import com.vci.starter.web.pagemodel.*; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.pagemodel.SessionInfo; import com.vci.starter.web.util.VciBaseUtil; +import com.vci.starter.web.util.VciDateUtil; import com.vci.starter.web.util.WebThreadLocalUtil; +import com.vci.web.service.OsBtmServiceI; import com.vci.web.service.UIManagerServiceI; +import com.vci.web.util.*; +import org.apache.commons.lang3.StringUtils; import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.UITools; @@ -24,17 +31,17 @@ 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 javax.swing.text.JTextComponent; +import javax.swing.tree.TreePath; import java.io.IOException; import java.util.*; -import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.regex.Pattern; /** * UI瀹氫箟鏈嶅姟鐣岄潰鐩稿叧鎺ュ彛 @@ -50,6 +57,18 @@ @Resource private PlatformClientUtil platformClientUtil; + /*** + * 鏄惁鏄鐞嗗憳 + */ + @Autowired + RightControlUtil rightControlUtil; + + /** + * 涓氬姟绫诲瀷 + */ + @Resource + private OsBtmServiceI osBtmServiceI; + /** * 鏃ュ織 */ @@ -62,6 +81,16 @@ @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())); } }; @@ -95,6 +124,37 @@ List<PLUILayout> pluiLayouts = Arrays.asList(res); dataGrid.setData(pluiLayouts); return dataGrid; + } + + /** + * ton閫氳繃涓氬姟绫诲瀷鍜屽悕绉版煡璇� + * @param btemName + * @param context + * @return + * @throws PLException + */ + public List<PLUILayout> getUIContextDataByBtName(String btemName,String context) throws PLException { + VciBaseUtil.alertNotNull(btemName,"涓氬姟绫诲瀷"); + List<PLUILayout> pluiLayoutList=new ArrayList<>(); + 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; } /** @@ -276,10 +336,13 @@ * 鏍规嵁涓婁笅鏂嘔D鍜屽尯鍩熺被鍨嬶紝鎸夐『搴忚幏鍙栧綋鍓嶅尯鍩熺殑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; } /** @@ -341,13 +404,46 @@ /** * 鏌ヨ椤甸潰璁捐瀹氫箟 - * @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; + /** + * 椤甸潰瀹氫箟鐨凞O2VO瀵硅薄 + * @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瀵硅薄杞琕O瀵硅薄鏃跺嚭鐜伴敊璇�,鍘熷洜锛�"+e.getMessage()); + } + }); + return plDefinationVOList; } /** @@ -473,15 +569,25 @@ */ @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); @@ -562,12 +668,333 @@ 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> getTabButtons(String pageDefinationOid) { + VciBaseUtil.alertNotNull(pageDefinationOid,"椤甸潰瀹氫箟涓婚敭"); + List<PLTabButton> buttonList = new ArrayList<>(); + try { + PLTabButton[] plTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(pageDefinationOid); + buttonList = Arrays.asList(plTabButtons); + List<PLTabButtonVO> plTabButtonVOList = this.tabButton2TabButtonVOS(buttonList); + PLTabButtonVO plTabButtonVO = new PLTabButtonVO(); + for(int i = 0; i < plTabButtonVOList.size(); i++){ + plTabButtonVO = plTabButtonVOList.get(i); + + if(plTabButtonVO.getParentOid().equals("")){ + plTabButtonVO.setChildren(plTabButtonVO2Children(plTabButtonVOList,plTabButtonVO.getOId())); + } + } + return plTabButtonVOList; + } catch (Exception e) { + e.printStackTrace(); + throw new VciBaseException("鍔犺浇椤电鍖哄煙鎸夐挳閰嶇疆淇℃伅寮傚父锛�" + e.getMessage()); + } + } + + /** + * 澶氫釜鎸夐挳閰嶇疆DO瀵硅薄杞涓猇O瀵硅薄 + * @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瀵硅薄杞琕O瀵硅薄 + * @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; + } + + /** + * 鎸夐挳閰嶇疆瀛愯妭鐐规煡鎵� + * @param plOid + * @param plTabButtonVOList + * @return + */ + private List<PLTabButtonVO> plTabButtonVO2Children(List<PLTabButtonVO> plTabButtonVOList, String plOid){ + ArrayList<PLTabButtonVO> plTabButtonVOS = new ArrayList<>(); + for (PLTabButtonVO plTabButtonVO : plTabButtonVOList) { + if(StringUtils.isBlank(plTabButtonVO.getParentOid())){ + continue; + } + if(plTabButtonVO.getParentOid().equals(plOid)){ + plTabButtonVO.setChildren(plTabButtonVO2Children(plTabButtonVOList,plOid)); + plTabButtonVOS.add(plTabButtonVO); + } + } + return plTabButtonVOS; + } + + /** + * 鎸夐挳閰嶇疆VO瀵硅薄杞珼O瀵硅薄 + * @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; + } + + /** + * 鍒犻櫎鍗曚釜鎸夐挳閰嶇疆 + * @param tabButton + * @return + */ + @Override + public boolean deleteTapButton(PLTabButton tabButton) throws PLException { + VciBaseUtil.alertNotNull(tabButton,"鍒犻櫎鐨勬寜閽厤缃璞�"); + boolean success = UITools.getService().deletePLTabButton(tabButton); + if(success == false){ + throw new VciBaseException("璇ユ湁瀛愮骇鎸夐挳锛屼笉鑳藉垹闄わ紒"); + } + return true; + } + + /** + * 璋冩暣涓轰笅绾ф寜閽� + * @param plTabButton + * @return + */ + @Override + public BaseResult joinBtn(PLTabButton plTabButton) throws PLException { + VciBaseUtil.alertNotNull(plTabButton,"闇�璋冩暣涓轰笅绾ф寜閽�",plTabButton.plTableOId,"褰撳墠鎸夐挳閰嶇疆鎵�鍦ㄧ殑椤甸潰涓婚敭"); + //鍚屼竴椤甸潰涓嬬殑鎸夐挳 + List<PLTabButtonVO> plTabButtons = this.getTabButtons(plTabButton.plTableOId); + if(Func.isEmpty(plTabButtons)){ + return BaseResult.fail("鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�"); + } + //鑾峰彇褰撳墠瑕佺Щ鍔ㄧ殑鎸夐挳鐨勪笅鏍� + int index = 0; + for (int i = 0; i < plTabButtons.size(); i++) { + if (plTabButtons.get(i).getOId().equals(plTabButton.plOId)) { + index = i; // 鎵惧埌鍚庤褰曚笅鏍� + break; // 鎵惧埌鍚庨��鍑哄惊鐜� + } + } + //褰撻�夋嫨鐨勬寜閽负鏍戠殑绗竴涓妭鐐圭殑鏃跺�欙紝浠栫殑鍏勮妭鐐规槸浠栬嚜宸憋紝瀵艰嚧璋冩暣涓轰笅绾ф寜閽椂鍑洪敊锛屾晠浣滄鍒ゆ柇銆� + if(index == 0){ + return BaseResult.fail("褰撳墠鑺傜偣涓嶅瓨鍦ㄥ厔鑺傜偣锛屾棤娉曡皟鏁翠负涓嬬骇鎸夐挳锛�"); + } + //璁剧疆鐖秈d涓轰笂涓�涓妭鐐圭殑 + plTabButton.plParentOid = plTabButtons.get(index-1).getOId(); + + boolean success = platformClientUtil.getUIService().updatePLTabButton(plTabButton); + if(success == false) { + return BaseResult.fail("淇敼澶辫触锛�"); + } + return BaseResult.fail("淇敼鎴愬姛锛�"); + } + + /** + * 璋冩暣涓轰笂绾ф寜閽� + * @param plTabButton + * @return + */ + @Override + public BaseResult exitBtn(PLTabButton plTabButton) throws PLException { + plTabButton.plParentOid = ""; + + boolean success = platformClientUtil.getUIService().updatePLTabButton(plTabButton); + if(success == false) { + BaseResult.fail("鎾ら攢澶辫触锛�"); + } + return BaseResult.success("鎾ら攢鎴愬姛锛�"); } /** @@ -610,18 +1037,6 @@ } 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; } @@ -726,6 +1141,422 @@ } /** + * 鑾峰彇UI鎺堟潈鏍� + * @param treeQueryObject + * @return + * @throws Exception + */ + @Override + public List<Tree> getUIAuthor(BaseQueryObject treeQueryObject) throws Exception { + + Map<String, String> conditionMap = treeQueryObject.getConditionMap(); + if (conditionMap == null) { + conditionMap = new HashMap<>(); + } + String roleId = StringUtils.isBlank(conditionMap.get("roleId")) ? "" : conditionMap.get("roleId"); + String type = StringUtils.isBlank(conditionMap.get("type")) ? "" : conditionMap.get("type"); + String context = StringUtils.isBlank(conditionMap.get("context")) ? "" : conditionMap.get("context"); + boolean showCheckBox = Boolean.parseBoolean(conditionMap.get("showCheckBox")); + Map<String,RoleRightVO> roleRightVOMap=new HashMap<>(); + if(StringUtils.isNotBlank(roleId)){ + String userName= WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); + RoleRightInfo[] rightInfos= platformClientUtil.getFrameworkService().getRoleRightList(roleId,userName); + List<RoleRightVO> roleRightVOList=roleRightDOO2VOS(Arrays.asList(rightInfos)); + roleRightVOMap=roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO)); + } + BizType[] bizTypes=osBtmServiceI.getBizTypes(type); + List<Tree> treeList=new ArrayList<>(); + Tree rootNode =new Tree("root","鍔熻兘妯″潡","root"); + rootNode.setLevel(0); + rootNode.setShowCheckbox(true); + rootNode.setExpanded(true); + List<Tree> childList=new ArrayList<>(); + for (int i = 0; i < bizTypes.length; i++) { + Tree bizTypeTree = new Tree(bizTypes[i].oid,bizTypes[i].name,bizTypes[i]);//(btmItems[i].label+" ["+ btmItems[i].name+"]", btmItems[i]); + bizTypeTree.setLevel(1); + bizTypeTree.setShowCheckbox(true); + bizTypeTree.setParentId(rootNode.getOid()); + bizTypeTree.setParentName(rootNode.getText()); + bizTypeTree.setShowCheckbox(true); + bizTypeTree.setParentBtmName(bizTypes[i].name); + childList.add(bizTypeTree); + 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; + } + + /*** + * UI鎺堟潈 + * @param uiAuthorDTO + * @return + * @throws Exception + */ + @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<>(); + 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(); + getSelectedRoleRightObjs(uiAuthorDTO.getRoleId(),selectTreeList,allTreeMap,roleRightDTOList); + } + return res; + } + + /** + * + * @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 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; + } + + /** + * + * @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(); + List<Tree> chiledTreeList=new ArrayList<>(); + if (funcObj instanceof BizType) {//涓氬姟绫诲瀷 + BizType bizType = (BizType) funcObj; + if(!CollectionUtil.isEmpty(contextList)) { + 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); + chiledTreeList.add(childTree); + }); + pTree.setChildren(chiledTreeList); + } + if(!CollectionUtil.isEmpty(chiledTreeList)) { + setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox); + } + }else if (funcObj instanceof PLUILayout){//UI + PLUILayout context = (PLUILayout) funcObj; + PLTabPage[] pages = new PLTabPage[0]; + try { + pages = platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(context.plOId); + } catch (PLException e) { + e.printStackTrace(); + } + if(pages!=null&&pages.length>0){ + List<PLTabPage> plTabPageList= Arrays.stream(pages).collect(Collectors.toList()); + plTabPageList.stream().forEach(plTabPage -> { + 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); + }); + pTree.setChildren(chiledTreeList); + } + if(!CollectionUtil.isEmpty(chiledTreeList)) { + setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox); + } + + }else if (funcObj instanceof PLTabPage) {//涓婁笅鏂� + PLTabPage plTabPage = (PLTabPage) funcObj; + List<PLPageDefination>plPageDefinationList=new ArrayList<>(); + try { + PLPageDefination[] pLPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(plTabPage.plOId); + if(pLPageDefinations!=null&&pLPageDefinations.length>0){ + plPageDefinationList= Arrays.stream(pLPageDefinations).collect(Collectors.toList()); + plPageDefinationList.stream().forEach(plPageDefination -> { + 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); + }); + pTree.setChildren(chiledTreeList); + } + if(!CollectionUtil.isEmpty(chiledTreeList)) { + setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox); + } + } catch (PLException e) { + e.printStackTrace(); + } + + }else if (funcObj instanceof PLPageDefination) {// + PLPageDefination plPageDefination = (PLPageDefination) funcObj; + try { + List<PLTabButton>plTabButtonList=new ArrayList<>(); + PLTabButton[] pLTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(plPageDefination.plOId); + if(pLTabButtons!=null&&pLTabButtons.length>0){ + plTabButtonList= Arrays.stream(pLTabButtons).collect(Collectors.toList()); + plTabButtonList.stream().forEach(plTabButton -> { + 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); + chiledTreeList.add(childTree); + }); + pTree.setChildren(chiledTreeList); + } + if(!CollectionUtil.isEmpty(chiledTreeList)) { + setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox); + } + } catch (PLException e) { + e.printStackTrace(); + } + + }else if (funcObj instanceof PLTabButton) {//鎸夐挳 + PLTabButton plTabButton= (PLTabButton) funcObj; + String id =plTabButton.plTableOId; + if(roleRightVOMap.containsKey(id)){ + 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); + } + } + }); + } + + /** + * UI瑙掕壊瀵硅薄杞崲 + * @param infos + * @return + */ + private List<RoleRightVO> roleRightDOO2VOS(List<RoleRightInfo> infos){ + List<RoleRightVO> roleRightVOS=new ArrayList<>(); + Optional.ofNullable(infos).orElseGet(()->new ArrayList<>()).stream().forEach(info -> { + RoleRightVO vo=roleRightDOO2VO(info); + roleRightVOS.add(vo); + }); + + return roleRightVOS; + } + + /** + * UI瑙掕壊瀵硅薄杞崲 + * @param info + * @return + */ + private RoleRightVO roleRightDOO2VO(RoleRightInfo info){ + RoleRightVO vo=new RoleRightVO(); + vo.setId(info.id); + vo.setCreateTime(VciDateUtil.date2Str(VciDateUtil.long2Date(info.createTime),"")); + vo.setCreateUser(info.createUser); + vo.setRoleId(info.roleId); + vo.setRightType(info.rightType); + vo.setLicensor(info.licensor); + vo.setRightValue(info.rightValue); + vo.setFuncId(info.funcId); + vo.setModifyTime(VciDateUtil.date2Str(VciDateUtil.long2Date(info.modifyTime),"")); + vo.setModifyUser(info.modifyUser); + return vo; + } + + /** * 鎺у埗鍖鸿妭鐐瑰強鍏跺瓙鑺傜偣鐨勫厠闅� * @param obj */ -- Gitblit v1.9.3