From a899eae792897cb014b9291562f32f5786cfb1f4 Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期四, 16 一月 2025 15:51:13 +0800
Subject: [PATCH] UI授权后,由于一个用户拥有多个角色问题,没有权限的角色可能会把有权限的角色数据替换,进行修改

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java |  328 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 214 insertions(+), 114 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java
index 9d6182c..e989fdf 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java
@@ -4,26 +4,21 @@
 import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
 import com.thoughtworks.xstream.io.xml.XppDriver;
-import com.vci.client.common.providers.ServiceProvider;
 import com.vci.corba.common.PLException;
+import com.vci.corba.framework.data.RoleRightInfo;
 import com.vci.corba.portal.data.*;
+import com.vci.pagemodel.*;
 import com.vci.starter.web.annotation.log.VciUnLog;
 import com.vci.starter.web.exception.VciBaseException;
-import com.vci.starter.web.util.BeanUtil;
-import com.vci.starter.web.util.LangBaseUtil;
-import com.vci.starter.web.util.VciBaseUtil;
-import com.vci.starter.web.util.VciDateUtil;
+import com.vci.starter.web.util.*;
+import com.vci.starter.web.util.Lcm.Func;
 import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
-import com.vci.web.constant.CacheKeyConstant;
 import com.vci.web.enumpck.UIComponentDisplayTypeEnum;
 import com.vci.web.enumpck.UIComponentTypeEnum;
 import com.vci.web.enumpck.UIFieldTypeEnum;
 import com.vci.web.enumpck.UILayoutAreaTypeEnum;
-import com.vci.web.pageModel.*;
-import com.vci.web.service.OsAttributeServiceI;
-import com.vci.web.service.OsBtmServiceI;
-import com.vci.web.service.UIEngineServiceI;
-import com.vci.web.service.WebBoServiceI;
+import com.vci.web.other.AllActionThreadLocal;
+import com.vci.web.service.*;
 import com.vci.web.util.PlatformClientUtil;
 import com.vci.web.util.WebUtil;
 import com.vci.web.xmlmodel.UIComponentDefineXO;
@@ -33,9 +28,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.cache.annotation.Caching;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
@@ -43,8 +35,7 @@
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.vci.web.constant.CacheNameConstant.VCI_OBJECT_SERVICE;
-import static com.vci.web.constant.EnumIdConstant.LC_STATUS_SUBFIX;
+import static com.vci.constant.EnumIdConstant.LC_STATUS_SUBFIX;
 
 /**
  * UI寮曟搸鏈嶅姟锛屼互鍓嶅钩鍙板皝瑁呭埌action閲岀殑锛�
@@ -90,10 +81,16 @@
 	private OsBtmServiceI btmService;
 
 	/**
-	 * 涓氬姟绫诲瀷鐨勬湇鍔�
+	 * 灞炴�х殑鏈嶅姟
 	 */
 	@Autowired
-	private WebBoServiceI boService;
+	private OsAttributeServiceI attrService;
+
+	/**
+	 * UI瀹氫箟绠$悊鏈嶅姟
+	 */
+	@Autowired
+	private UIManagerServiceI uiManagerServiceI;
 
 	/**
 	 * 琛ㄥ崟鐨勫瓧娈电被鍨嬫槧灏�
@@ -136,8 +133,7 @@
 	public void checkInvalidXmlVI() {
 		PortalVI[] portalVIS = null;
 		try {
-			portalVIS = ServiceProvider.getUIService().getAllPortalVI();
-			// portalVIS = platformClientUtil.getPortalService().getAllPortalVI();
+			portalVIS = platformClientUtil.getUIService().getAllPortalVI();
 		} catch (PLException vciError) {
 			throw WebUtil.getVciBaseException(vciError);
 		}
@@ -161,7 +157,7 @@
 	public List<UIFormDefineVO> selectAllForm() {
 		PortalVI[] portalVIS = null;
 		try {
-			portalVIS = ServiceProvider.getUIService().getAllPortalVI();
+			portalVIS = platformClientUtil.getUIService().getAllPortalVI();
 		} catch (PLException vciError) {
 			throw WebUtil.getVciBaseException(vciError);
 		}
@@ -175,7 +171,6 @@
 	 * @return key鏄〃鍗曡嫳鏂囧悕绉�
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_FORM,unless = "#result == null")
 	public Map<String, UIFormDefineVO> selectAllFormMap() {
 		return Optional.ofNullable(self.selectAllForm()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getBtmType().toLowerCase() + SEP + s.getId().toLowerCase(),t->t,(o1,o2)->o1));
 	}
@@ -325,7 +320,13 @@
 					//璇存槑鏄摼鎺ョ被鍨�
 					field = field.substring("t_oid.".length());
 				}
-				OsAttributeVO attributeVO = attributeService.getAttr(field);
+//				OsAttributeVO attributeVO = attributeService.getAttr(field);
+				OsAttributeVO attributeVO = null;
+				try {
+					attributeVO = attributeService.attributeDO2VO(platformClientUtil.getAttributeService().getAttributeDefByName(field));
+				} catch (PLException e) {
+					throw new RuntimeException(e);
+				}
 				UIFormReferVO referVO = new UIFormReferVO();
 				if(attributeVO !=null && StringUtils.isNotBlank(attributeVO.getBtmTypeId())
 						&& StringUtils.isBlank(itemXO.getRefer())
@@ -404,21 +405,17 @@
 	 * @return 琛ㄥ崟鐨勫畾涔�
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = "#p0.concat('${formcache}').concat(#p1)",unless = "#result == null || #p0 == null || #p1 == null")
 	public UIFormDefineVO getFormById(String btmId, String id) {
 		if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){
 			return null;
 		}
-		if(!QUERY_BY_CACHE){
-			PortalVI portalVI = null;
-			try {
-				portalVI = ServiceProvider.getUIService().getPortalVIByTypeNameAndVIName(btmId, id);
-			} catch (PLException vciError) {
-				throw WebUtil.getVciBaseException(vciError);
-			}
-			return formDO2VO(portalVI);
+		PortalVI portalVI = null;
+		try {
+			portalVI = platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmId, id);
+		} catch (PLException vciError) {
+			throw WebUtil.getVciBaseException(vciError);
 		}
-		return self.selectAllFormMap().getOrDefault(btmId.toLowerCase()+SEP+id.toLowerCase(),null);
+		return formDO2VO(portalVI);
 	}
 
 	/**
@@ -450,12 +447,11 @@
 	 * @return 琛ㄦ牸鐨勫畾涔�
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_TABLE,unless = "#result == null")
 	@VciUnLog
 	public List<UITableDefineVO> selectAllTable() {
 		PortalVI[] portalVIS = null;
 		try {
-			portalVIS = ServiceProvider.getUIService().getAllPortalVI();
+			portalVIS = platformClientUtil.getUIService().getAllPortalVI();
 		} catch (PLException vciError) {
 			throw WebUtil.getVciBaseException(vciError);
 		}
@@ -485,7 +481,12 @@
 	public List<UITableDefineVO> tableDO2VOs(Collection<PortalVI> prms, boolean queryDetail) {
 		List<UITableDefineVO> tableDefineVOList = new ArrayList<>();
 		Optional.ofNullable(prms).orElseGet(()->new ArrayList<PortalVI>()).stream().forEach(portal->{
-			UITableDefineVO defineVO = tableDO2VO(portal,queryDetail);
+			UITableDefineVO defineVO = null;
+			try {
+				defineVO = tableDO2VO(portal,queryDetail,null);
+			} catch (PLException e) {
+				throw new RuntimeException(e);
+			}
 			tableDefineVOList.add(defineVO);
 		});
 		return tableDefineVOList;
@@ -500,7 +501,7 @@
 	 */
 	@Override
 	@VciUnLog
-	public UITableDefineVO tableDO2VO(PortalVI portal, boolean queryDetail) {
+	public UITableDefineVO tableDO2VO(PortalVI portal, boolean queryDetail, Map<String, OsAttributeVO> attributeVOMap) throws PLException {
 		UITableDefineVO tableDefineVO = new UITableDefineVO();
 		tableDefineVO.setOid(portal.id);
 		tableDefineVO.setId(portal.viName);
@@ -531,7 +532,7 @@
 			self.selectAllForm().stream().filter(s -> formOid.equalsIgnoreCase(s.getOid())).findAny().orElseGet(() -> null);
 		}else{
 			try {
-				formDefineVO = formDO2VO(ServiceProvider.getUIService().getPortalVIById(formOid));
+				formDefineVO = formDO2VO(platformClientUtil.getUIService().getPortalVIById(formOid));
 			} catch (PLException vciError) {
 				throw WebUtil.getVciBaseException(vciError);
 			}
@@ -605,7 +606,7 @@
 							fieldVO.setSortField(fieldName);
 							fieldVO.setEdit("combox");
 							//鑲畾鏄笟鍔$被鍨嬶紝鍥犱负閾炬帴绫诲瀷娌℃湁杩欎釜瀛楁
-							OsBtmTypeVO btmTypeVO = btmService.getBtmById(tableDefineVO.getBtmType());
+							OsBtmTypeVO btmTypeVO = btmService.btmDO2VO(platformClientUtil.getBtmService().getBizTypeByName(tableDefineVO.getBtmType()),attributeVOMap);
 							if(btmTypeVO!=null && StringUtils.isNotBlank(btmTypeVO.getLifeCycleId())){
 								fieldVO.setComboxKey(btmTypeVO.getLifeCycleId() + LC_STATUS_SUBFIX);
 							}
@@ -654,7 +655,7 @@
 						&& !UIFieldTypeEnum.CUSTOM.getValue().equalsIgnoreCase(s.getFieldType())).forEach(fieldVO->{
 					//鍒楄〃閲岄潰涓嶆斁edit锛岃�屾煡璇㈤噷闈㈤渶瑕佹斁edit
 					UITableFieldVO queryFieldVO = new UITableFieldVO();
-					BeanUtil.convert(fieldVO,queryFieldVO);
+					BeanUtilForVCI.convert(fieldVO,queryFieldVO);
 					canQueryFields.add(queryFieldVO);
 				});
 				tableDefineVO.setSeniorQueryColumns(canQueryFields);
@@ -724,19 +725,18 @@
 	 * @return 琛ㄥ崟鐨勫畾涔�
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = "#p0.concat('${tablecache}').concat(#p1)",unless = "#result == null || #p0 == null || #p1 == null")
-	public UITableDefineVO getTableById(String btmId, String id) {
+	public UITableDefineVO getTableById(String btmId, String id) throws PLException {
 		if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){
 			return null;
 		}
 		if(!QUERY_BY_CACHE){
 			PortalVI portalVI = null;
 			try {
-				portalVI = ServiceProvider.getUIService().getPortalVIByTypeNameAndVIName(btmId, id);
+				portalVI = platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmId, id);
 			} catch (PLException vciError) {
 				throw WebUtil.getVciBaseException(vciError);
 			}
-			return tableDO2VO(portalVI,true);
+			return tableDO2VO(portalVI,true,null);
 		}
 		return self.selectAllTableMap().getOrDefault(btmId.toLowerCase()+SEP+id.toLowerCase(),null);
 	}
@@ -773,8 +773,7 @@
 	@VciUnLog
 	public List<UIActionVO> selectAllAction() {
 		try {
-//			return actionDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLAction()).collect(Collectors.toList()));
-			return actionDO2VOs(Arrays.stream(ServiceProvider.getUIService().getAllPLAction()).collect(Collectors.toList()));
+			return actionDO2VOs(Arrays.stream(platformClientUtil.getUIService().getAllPLAction()).collect(Collectors.toList()));
 		} catch (PLException vciError) {
 			throw WebUtil.getVciBaseException(vciError);
 		}
@@ -786,7 +785,6 @@
 	 * @return 鏄剧ず瀵硅薄锛宬ey鏄痑ction鐨勪富閿�
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key=CacheKeyConstant.ALL_ACTION,unless = "#result == null")
 	public Map<String, UIActionVO> selectAllActionMap() {
 		return Optional.ofNullable(self.selectAllAction()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t));
 	}
@@ -843,13 +841,6 @@
 	 * 娓呴櫎缂撳瓨
 	 */
 	@Override
-	@Caching(evict = {
-			@CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_UI),
-			@CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_ACTION),
-			@CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_FORM),
-			@CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_TABLE),
-			@CacheEvict(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_FORM_AND_TABLE)
-	})
 	public void clearCache()  {
 
 	}
@@ -861,7 +852,6 @@
 	 */
 	@Override
 	@VciUnLog
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_UI,unless = "#result == null")
 	public List<UIContentVO> selectAllUIContent() {
 		try {
 			return UIContentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLUILayouts()).collect(Collectors.toList()));
@@ -878,7 +868,7 @@
 	private List<UIContentVO> UIContentDO2VOs(Collection<PLUILayout> pageLayoutDefinations){
 		List<UIContentVO> contentVOS = new ArrayList<>();
 		Optional.ofNullable(pageLayoutDefinations).orElseGet(()->new ArrayList<PLUILayout>()).stream().forEach(pageLayout->{
-			contentVOS.add(UIContentDO2VO(pageLayout,false));
+			contentVOS.add(UIContentDO2VO(pageLayout,false,null));
 		});
 		if(!CollectionUtils.isEmpty(contentVOS)) {
 			Map<String, List<UILayoutVO>> layoutMap = batchListLayoutByContent(contentVOS.stream().map(UIContentVO::getOid).collect(Collectors.toSet()));
@@ -904,7 +894,7 @@
 	 */
 	@VciUnLog
 	@Override
-	public UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail){
+	public UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail,Map<String, List<RoleRightVO>> roleRightMap){
 		UIContentVO contentVO = new UIContentVO();
 		if(pageLayoutDefination !=null){
 			contentVO.setOid(pageLayoutDefination.plOId);
@@ -922,18 +912,20 @@
 			contentVO.setLastModifier(pageLayoutDefination.plModifyUser);
 			if(queryDetail){
 				//鏌ヨ鍖呭惈鐨勫唴瀹�
-				List<UILayoutVO> layoutVOS = listLayoutByContent(contentVO.getOid());
+				List<UILayoutVO> layoutVOS = null;
+				//鍒ゆ柇鏄惁鏍规嵁鏉冮檺杩斿洖
+				layoutVOS = listLayoutByContent(contentVO.getOid(),roleRightMap);
 				if(!CollectionUtils.isEmpty(layoutVOS)){
 					if(layoutVOS.size() == 1){
 						//鍙湁涓�涓尯鍩�
 						UILayoutVO layoutVO = layoutVOS.get(0);
 						List<UIComponentVO> componentVOs = layoutVO.getComponentVOs();
 						//绗竴涓綔涓篶enter
-						UIComponentVO firstCompVO = componentVOs.stream().min((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum())).get();
+						UIComponentVO firstCompVO = componentVOs.stream().min(Comparator.comparing(UIComponentVO::getOrderNum)).get();
 						List<UIComponentVO> southCompVO = componentVOs.stream().filter(s->!s.getOid().equals(firstCompVO.getOid())).collect(Collectors.toList());
 
 						UILayoutVO centerVO = new UILayoutVO();
-						BeanUtil.convert(layoutVO,centerVO);
+						BeanUtilForVCI.convert(layoutVO,centerVO);
 						centerVO.setOid(centerVO.getOid() + "_center");
 						centerVO.setLayoutAreaType(UILayoutAreaTypeEnum.CENTER.getValue());
 						centerVO.setOrderNum(0);
@@ -951,7 +943,7 @@
 						//鍏朵綑鐨勪綔涓簊outh
 						if(!CollectionUtils.isEmpty(southCompVO)) {
 							UILayoutVO southVO = new UILayoutVO();
-							BeanUtil.convert(layoutVO, southVO);
+							BeanUtilForVCI.convert(layoutVO, southVO);
 							southVO.setOid(centerVO.getOid() + "_south");
 							southVO.setLayoutAreaType(UILayoutAreaTypeEnum.SOUTH.getValue());
 							southVO.setOrderNum(0);
@@ -1018,16 +1010,79 @@
 	//	}
 
 	/**
-	 * 鑾峰彇鏌愪釜UI涓婁笅鏂囩殑鍖哄煙
+	 * 鑾峰彇鏌愪釜UI涓婁笅鏂囩殑鍖哄煙锛屾牴鎹潈闄愭帶鍒惰繑鍥�
 	 * @param pkContent UI涓婁笅鏂囩殑涓婚敭
 	 * @return 涓婁笅鏂�
 	 */
-	private List<UILayoutVO> listLayoutByContent(String pkContent){
+	private List<UILayoutVO> listLayoutByContent(String pkContent,Map<String, List<RoleRightVO>> roleRightMap){
 		try {
-			return UILayoutDO2VOs(Arrays.stream(ServiceProvider.getUIService().getPLTabPagesByPageDefinationOId(pkContent)).collect(Collectors.toList()),true);
+			List<PLTabPage> tabPageList = Arrays.stream(platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(pkContent)).collect(Collectors.toList());
+			//杩囨护鎺夋病鏈夎闂潈闄愮殑UI
+			tabPageList = this.filterTabPageByRoleRight(tabPageList,roleRightMap);
+			return UILayoutDO2VOs(tabPageList,true,roleRightMap);
 		} catch (PLException vciError) {
 			throw WebUtil.getVciBaseException(vciError);
 		}
+	}
+
+	/**
+	 * 鏍规嵁鏉冮檺闆嗗悎杩囨护鎺夋病鏈夎闂潈闄愮殑椤电鏁版嵁
+	 * @param tabPageList
+	 * @param roleRightMap
+	 */
+	private List<PLTabPage> filterTabPageByRoleRight(List<PLTabPage> tabPageList, Map<String, List<RoleRightVO>> roleRightMap){
+		if(Func.isEmpty(roleRightMap) || Func.isEmpty(tabPageList)){
+			return tabPageList;
+		}
+		List<PLTabPage> filterList = new ArrayList<>();
+		for (int i = 0; i < tabPageList.size(); i++) {
+			PLTabPage tabPage = tabPageList.get(i);
+			if(roleRightMap.containsKey(tabPage.plOId)){
+				filterList.add(tabPage);
+			}
+			/*if(roleRightMap.containsKey(tabPage.plContextOId)) {
+				Long rightValue = roleRightMap.get(tabPage.plContextOId).getRightValue();
+				int nodeValue = tabPage.plSeq;
+				if (nodeValue >= 0 && nodeValue <= 63) {
+					//杩涜浣嶄笌鎿嶄綔锛屽鏋滅浉绛夊垯琛ㄧず鍏锋湁褰撳墠鎿嶄綔鐨勬潈闄�
+					long preValue = (rightValue >> nodeValue) & 1;
+					if (preValue != 1) {
+						tabPageList.remove(tabPage);
+					}
+				}
+			}*/
+		}
+		return filterList;
+	}
+
+	/**
+	 * 鏍规嵁鏉冮檺闆嗗悎杩囨护鎺夋病鏈夎闂潈闄愮殑椤甸潰瀹氫箟鏁版嵁
+	 * @param plPageDefinationList
+	 * @param roleRightMap
+	 */
+	private List<PLPageDefination> filterPageDefByRoleRight(List<PLPageDefination> plPageDefinationList, Map<String, List<RoleRightVO>> roleRightMap){
+		if(Func.isEmpty(roleRightMap) || Func.isEmpty(plPageDefinationList)){
+			return plPageDefinationList;
+		}
+		List<PLPageDefination> filterList = new ArrayList<>();
+		for (int i = 0; i < plPageDefinationList.size(); i++) {
+			PLPageDefination plPageDefination = plPageDefinationList.get(i);
+			if(roleRightMap.containsKey(plPageDefination.plOId)){
+				filterList.add(plPageDefination);
+			}
+			/*if(roleRightMap.containsKey(plPageDefination.plTabPageOId)) {
+				Long rightValue = roleRightMap.get(plPageDefination.plTabPageOId).getRightValue();
+				int nodeValue = plPageDefination.seq;
+				if (nodeValue >= 0 && nodeValue <= 63) {
+					//杩涜浣嶄笌鎿嶄綔锛屽鏋滅浉绛夊垯琛ㄧず鍏锋湁褰撳墠鎿嶄綔鐨勬潈闄�
+					long preValue = (rightValue >> nodeValue) & 1;
+					if (preValue != 1) {
+						plPageDefinationList.remove(plPageDefination);
+					}
+				}
+			}*/
+		}
+		return filterList;
 	}
 
 	/**
@@ -1067,7 +1122,6 @@
 	 * @return 鍖哄煙鐨勬樉绀哄璞�
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_LAYOUT,unless = "#result == null")
 	public List<UILayoutVO> selectAllUILayout() {
 //		try {
 //			return UILayoutDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLTabPages()).collect(Collectors.toList()),true);
@@ -1082,10 +1136,21 @@
 	 * @param pages 鍖哄煙鐨勬暟鎹璞�
 	 * @return 鏄剧ず瀵硅薄
 	 */
-	private List<UILayoutVO> UILayoutDO2VOs(Collection<PLTabPage> pages, boolean queryDetail){
+	private List<UILayoutVO> UILayoutDO2VOs(Collection<PLTabPage> pages, boolean queryDetail, Map<String, List<RoleRightVO>> roleRightMap){
 		List<UILayoutVO> contentVOS = new ArrayList<>();
+		Map<String, OsAttributeVO> attributeVOMap;
+		if(pages != null && pages.size() > 0){
+			attributeVOMap = attrService.selectAllAttributeMap();
+			Map<String, UIActionVO> actionVOMap = AllActionThreadLocal.get();
+			if(actionVOMap == null || actionVOMap.isEmpty()){
+				actionVOMap = selectAllActionMap();
+				AllActionThreadLocal.set(actionVOMap);
+			}
+		}else{
+			attributeVOMap = null;
+		}
 		Optional.ofNullable(pages).orElseGet(()->new ArrayList<PLTabPage>()).stream().forEach(page->{
-			UILayoutVO layoutVO = UILayoutDO2VO(page, queryDetail);
+			UILayoutVO layoutVO = UILayoutDO2VO(page, queryDetail,attributeVOMap,roleRightMap);
 			if(layoutVO.isEnableStatus()) {
 				contentVOS.add(layoutVO);
 			}
@@ -1098,6 +1163,7 @@
 				}
 			});
 		}
+		AllActionThreadLocal.remove();
 		return contentVOS;
 	}
 
@@ -1108,7 +1174,7 @@
 	 * @return 鍖哄煙鐨勬樉绀哄璞�
 	 */
 	@VciUnLog
-	private UILayoutVO UILayoutDO2VO(PLTabPage page, boolean queryDetail){
+	private UILayoutVO UILayoutDO2VO(PLTabPage page, boolean queryDetail,Map<String, OsAttributeVO> attributeVOMap, Map<String, List<RoleRightVO>> roleRightMap){
 		UILayoutVO layoutVO = new UILayoutVO();
 		if(page !=null ){
 			layoutVO.setOid(page.plOId);
@@ -1148,8 +1214,10 @@
 			if(queryDetail){
 				//鍗曚釜鐨勶紝鐩存帴鑾峰彇
 				try {
-					layoutVO.setComponentVOs(uiComponentDO2VOs(Arrays.stream(ServiceProvider.getUIService().getPLPageDefinationsByPageContextOId(layoutVO.getOid())).collect(Collectors.toList()),true));
-//					layoutVO.setComponentVOs(uiComponentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getPLPageDefinationsByPageContextOId(layoutVO.getOid())).collect(Collectors.toList()),true));
+					List<PLPageDefination> pageDefinationList = Arrays.stream(platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(layoutVO.getOid())).collect(Collectors.toList());
+					pageDefinationList = this.filterPageDefByRoleRight(pageDefinationList,roleRightMap);
+					List<UIComponentVO> uiComponentVOS = uiComponentDO2VOs(pageDefinationList, true, attributeVOMap,roleRightMap);
+					layoutVO.setComponentVOs(uiComponentVOS);
 				} catch (PLException vciError) {
 					throw WebUtil.getVciBaseException(vciError);
 				}
@@ -1157,6 +1225,7 @@
 		}
 		return layoutVO;
 	}
+
 	/**
 	 * 鏌ヨ鎵�鏈夌殑涓婁笅鏂囩殑鍖哄煙鐨勬槧灏�
 	 *
@@ -1173,7 +1242,6 @@
 	 * @return UI缁勪欢
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = CacheKeyConstant.ALL_COMP ,unless = "#result ==null")
 	public List<UIComponentVO> selectAllUIComponent() {
 //		try {
 //			return uiComponentDO2VOs(Arrays.stream(platformClientUtil.getPortalService().getAllPLPageDefinations()).collect(Collectors.toList()),false);
@@ -1190,24 +1258,15 @@
 	 * @return 涓婚敭鐨勬樉绀哄璞�
 	 */
 	@Override
-	public UIComponentVO getComponentByOid(String componentOid) {
+	public UIComponentVO getComponentByOid(String componentOid, Map<String, OsAttributeVO> attributeVOMap) {
 		if(StringUtils.isBlank(componentOid)){
 			return null;
 		}
-		if(!QUERY_BY_CACHE){
-			try {
-				return uiComponentDO2VO(ServiceProvider.getUIService().getPLPageDefinationById(componentOid),true);
-			} catch (PLException vciError) {
-				throw WebUtil.getVciBaseException(vciError);
-			}
-		}else{
-			List<UIComponentVO> componentVOS = self.selectAllUIComponent();
-			List<UIComponentVO> componentVOList = Optional.ofNullable(componentVOS).orElseGet(() -> new ArrayList<>()).stream().filter(s -> s.getOid().equalsIgnoreCase(componentOid)).collect(Collectors.toList());
-			if(!CollectionUtils.isEmpty(componentVOList)){
-				return componentVOList.get(0);
-			}
+		try {
+			return uiComponentDO2VO(platformClientUtil.getUIService().getPLPageDefinationById(componentOid),true,attributeVOMap,null);
+		} catch (PLException vciError) {
+			throw WebUtil.getVciBaseException(vciError);
 		}
-		return null;
 	}
 
 	/**
@@ -1215,10 +1274,10 @@
 	 * @param pages 鏁版嵁瀵硅薄
 	 * @return 鏄剧ず瀵硅薄
 	 */
-	private List<UIComponentVO> uiComponentDO2VOs(Collection<com.vci.corba.portal.data.PLPageDefination> pages, boolean queryDetail){
+	private List<UIComponentVO> uiComponentDO2VOs(Collection<PLPageDefination> pages, boolean queryDetail,Map<String, OsAttributeVO> attributeVOMap, Map<String, List<RoleRightVO>> roleRightMap){
 		List<UIComponentVO> componentVOS = new ArrayList<>();
 		pages.stream().forEach(page->{
-			componentVOS.add(uiComponentDO2VO(page,queryDetail));
+			componentVOS.add(uiComponentDO2VO(page,queryDetail,attributeVOMap,roleRightMap));
 		});
 		return componentVOS;
 	}
@@ -1229,7 +1288,7 @@
 	 * @return 鏄剧ず瀵硅薄
 	 */
 	@VciUnLog
-	private UIComponentVO uiComponentDO2VO(PLPageDefination page, boolean queryDetail){
+	private UIComponentVO uiComponentDO2VO(PLPageDefination page, boolean queryDetail, Map<String, OsAttributeVO> attributeVOMap, Map<String, List<RoleRightVO>> roleRightMap){
 		UIComponentVO componentVO = new UIComponentVO();
 		if(page !=null){
 			componentVO.setOid(page.plOId);
@@ -1237,6 +1296,7 @@
 			componentVO.setName(page.name);
 			componentVO.setDescription(page.desc);
 			componentVO.setOrderNum((int) page.seq);
+
 			UIComponentDefineXO componentDefineXO = null;
 			try {
 				componentDefineXO = readInfoFromXML(page.plDefination, UIComponentDefineXO.class);
@@ -1244,6 +1304,8 @@
 				logger.error("璇诲彇xml鍑洪敊",e);
 				return  null;
 			}
+			//鑷畾涔夋煡璇㈡柟寮�
+			componentVO.setBsDataModel(componentDefineXO.getBsDataModel());
 			//涔嬪墠鐨勭被鍨嬬殑鍊兼槸1锛�2锛�3绛夌湅鐫�涓嶇洿瑙�
 			UIComponentTypeEnum componentTypeEnum = null;
 			if("1".equals(componentDefineXO.getTemplateType())){
@@ -1268,8 +1330,7 @@
 					componentVO.setTableDefineVO(tableDefineVOMap.get(key));
 				}else{
 					try {
-						componentVO.setTableDefineVO(tableDO2VO(ServiceProvider.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true));
-						//componentVO.setTableDefineVO(tableDO2VO(platformClientUtil.getPortalService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true));
+						componentVO.setTableDefineVO(tableDO2VO(platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true,attributeVOMap));
 					} catch (PLException vciError) {
 						throw WebUtil.getVciBaseException(vciError);
 					}
@@ -1305,7 +1366,7 @@
 					tableDefineVO= tableDefineVOMap.get(key);
 				}else{
 					try {
-						tableDefineVO = tableDO2VO(ServiceProvider.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true);
+						tableDefineVO = tableDO2VO(platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId()),true,null);
 					} catch (PLException vciError) {
 						throw WebUtil.getVciBaseException(vciError);
 					}
@@ -1313,7 +1374,7 @@
 				if(tableDefineVO != null) {
 
 					UITreeTableDefineVO treeTableDefineVO = new UITreeTableDefineVO();
-					BeanUtil.convert(tableDefineVO, treeTableDefineVO);
+					BeanUtilForVCI.convert(tableDefineVO, treeTableDefineVO);
 					if(isLink){
 						treeTableDefineVO.setTreeCurrentField("t_oid");
 						treeTableDefineVO.setTreeParentField("f_oid");
@@ -1356,7 +1417,7 @@
 					componentVO.setFormDefineVO(formDefineVOMap.get(key));
 				}else{
 					try {
-						componentVO.setFormDefineVO(formDO2VO(ServiceProvider.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId())));
+						componentVO.setFormDefineVO(formDO2VO(platformClientUtil.getUIService().getPortalVIByTypeNameAndVIName(btmType,componentDefineXO.getTemplateId())));
 					} catch (PLException vciError) {
 						throw WebUtil.getVciBaseException(vciError);
 					}
@@ -1368,7 +1429,8 @@
 				treeDefineVO.setBtmType(componentDefineXO.getShowType());
 				treeDefineVO.setLinkType(componentDefineXO.getLinkType());
 				treeDefineVO.setLoadType("1".equalsIgnoreCase(componentDefineXO.getExpandMode())?"node":"all");
-				treeDefineVO.setOrientation("positive".equalsIgnoreCase(componentDefineXO.getOrientation())?false:true);
+				//TODO:杩欎釜灞炴�х幇鍦ㄧ敱閾炬帴绫诲瀷鏌ヨ妯℃澘閰嶇疆涓婃帶鍒讹紝涓嶅湪椤甸潰瀹氫箟鎺у埗浜�,浣嗘槸涓轰簡鍏煎浠ュ墠鐨刄I瀹氫箟鎵�浠ラ渶瑕佽�冭檻淇濈暀
+				treeDefineVO.setOrientation(componentDefineXO.getOrientation());
 				treeDefineVO.setShowImage("1".equalsIgnoreCase(componentDefineXO.getIsShowImage())?true:false);
 				treeDefineVO.setRootContent(componentDefineXO.getRootContent());
 				treeDefineVO.setFieldSep(StringUtils.isBlank(componentDefineXO.getSeparator())?",":componentDefineXO.getSeparator());
@@ -1393,20 +1455,49 @@
 			}
 			componentVO.setUiParseClass(componentDefineXO.getUIParser());
 			componentVO.setExtendAttr(componentDefineXO.getExtAttr());
-			componentVO.setButtons(listButtonByComponent(componentVO.getOid()));
+			componentVO.setButtons(listButtonByComponent(componentVO.getOid(),roleRightMap));
 		}
 		return componentVO;
 	}
 
 	/**
-	 * 鑾峰彇鏌愪釜缁勪欢鐨勬寜閽�
+	 * 鑾峰彇鏌愪釜缁勪欢鐨勬寜閽�(鏍规嵁鏉冮檺杩囨护)
 	 * @param pkComponent 缁勪欢鐨勪富閿�
 	 * @return 鎸夐挳鐨勪俊鎭�
 	 */
 	@Override
-	public List<UIButtonDefineVO> listButtonByComponent(String pkComponent){
+	public List<UIButtonDefineVO> listButtonByComponent(String pkComponent, Map<String, List<RoleRightVO>> roleRightMap){
 		try {
-			List<UIButtonDefineVO> buttonDefineVOS = buttonDO2VOs(Arrays.stream(ServiceProvider.getUIService().getPLTabButtonsByTableOId(pkComponent)).collect(Collectors.toSet())).stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList());
+			List<UIButtonDefineVO> buttonDefineVOS = buttonDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLTabButtonsByTableOId(pkComponent)).collect(Collectors.toSet())).stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList());
+			if(Func.isEmpty(roleRightMap)){
+				roleRightMap = uiManagerServiceI.getRoleRightMap(null);
+			}
+
+			//寰幆瀵规寜閽潈闄愯繘琛屽垽鏂紝娌℃湁鏉冮檺鐨勫皢绉婚櫎buttonDefineVOS瀵硅薄
+			Iterator<UIButtonDefineVO> buttonDefineVO = buttonDefineVOS.iterator();
+			while (buttonDefineVO.hasNext()){
+				UIButtonDefineVO buttonDefine = buttonDefineVO.next();
+				if(roleRightMap.containsKey(buttonDefine.getPkComponent())) {
+					List<Long> rightValues = roleRightMap.get(buttonDefine.getPkComponent()).stream()
+							.map(e -> e.getRightValue()).collect(Collectors.toList());
+					int nodeValue = buttonDefine.getOrderNum();
+					if (nodeValue >= 0 && nodeValue <= 63) {
+						boolean authFlag = false;
+						//杩涜浣嶄笌鎿嶄綔锛屽鏋滅浉绛夊垯琛ㄧず鍏锋湁褰撳墠鎿嶄綔鐨勬潈闄�
+						for (Long rightValue : rightValues) {
+							long preValue = (rightValue >> nodeValue) & 1;
+							if (preValue == 1) {
+								authFlag = true;
+								break;
+							}
+						}
+						if(!authFlag){
+							buttonDefineVO.remove();
+						}
+					}
+				}
+			}
+
 			if(CollectionUtils.isEmpty(buttonDefineVOS)){
 				return buttonDefineVOS;
 			}
@@ -1432,11 +1523,21 @@
 	 * @return 鏄剧ず瀵硅薄
 	 */
 	@Override
-	public List<UIButtonDefineVO> buttonDO2VOs(Collection<com.vci.corba.portal.data.PLTabButton> buttons){
+	public List<UIButtonDefineVO> buttonDO2VOs(Collection<PLTabButton> buttons){
 		List<UIButtonDefineVO> buttonDefineVOS = new ArrayList<>();
-		Optional.ofNullable(buttons).orElseGet(()->new ArrayList<>()).stream().forEach(button->{
-			buttonDefineVOS.add(buttonDO2VO(button));
-		});
+		if(buttons != null && buttons.size() > 0){
+//			Map<String, UIActionVO> actionVOMap = self.selectAllActionMap();
+			Map<String, UIActionVO> actionVOMap = null;
+			actionVOMap = AllActionThreadLocal.get();
+			if(actionVOMap == null ){
+				actionVOMap = self.selectAllActionMap();
+			}
+			Map<String, UIActionVO> finalActionVOMap = actionVOMap;
+			Optional.ofNullable(buttons).orElseGet(()->new ArrayList<>()).stream().forEach(button->{
+				buttonDefineVOS.add(buttonDO2VO(button, finalActionVOMap));
+			});
+		}
+
 		return buttonDefineVOS;
 	}
 
@@ -1446,9 +1547,8 @@
 	 * @return 鏄剧ず瀵硅薄
 	 */
 	@Override
-	public UIButtonDefineVO buttonDO2VO(com.vci.corba.portal.data.PLTabButton button)  {
+	public UIButtonDefineVO buttonDO2VO(PLTabButton button, Map<String, UIActionVO> actionVOMap)  {
 		UIButtonDefineVO buttonVO = new UIButtonDefineVO();
-		Map<String, UIActionVO> actionVOMap = self.selectAllActionMap();
 //		Map<String, UIActionVO> actionVOMap = ServiceProvider.getUIService().getAllPLAction();
 		if(button !=null){
 			buttonVO.setOid(button.plOId);
@@ -1480,8 +1580,7 @@
 				//鏌ユ壘鍙傛暟
 				Map<String,String> params = new HashMap<>();
 				try {
-					//PLCommandParameter[] parameters = platformClientUtil.getPortalService().getPLCommandParametersByCommandOId(buttonVO.getOid());
-					PLCommandParameter[] parameters = ServiceProvider.getUIService().getPLCommandParametersByCommandOId(buttonVO.getOid());
+					PLCommandParameter[] parameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(buttonVO.getOid());
 					if(parameters!=null && parameters.length > 0){
 						for(PLCommandParameter parameter: parameters){
 							params.put(parameter.plKey,parameter.plValue);
@@ -1542,18 +1641,18 @@
 	 * @return UI涓婁笅鏂囩殑淇℃伅
 	 */
 	@Override
-	@Cacheable(value = VCI_OBJECT_SERVICE,key = "#p0.concat('${uicache}').concat(#p1)",unless = "#result == null || #p0 == null || #p1 ==null")
-	public UIContentVO getUIContentByBtmTypeAndId(String btmType, String id) {
+	public UIContentVO getUIContentByBtmTypeAndId(String btmType, String id) throws PLException {
 		WebUtil.alertNotNull(btmType,"涓氬姟绫诲瀷鎴栬�呴摼鎺ョ被鍨�",id,"UI涓婁笅鏂囩殑缂栧彿");
 		PLUILayout[] obj = null;
 		try {
-			obj = ServiceProvider.getUIService().getPLUILayoutsByRelatedType(btmType);
-//			obj = platformClientUtil.getPortalService().getPLPageLayoutDefinationsByRelatedType(btmType);
-//			obj = ServiceProvider.geT(btmType);
-
+			obj = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(btmType);
 		} catch (PLException vciError) {
 			throw WebUtil.getVciBaseException(vciError);
 		}
+		// 1銆佹牴鎹綋鍓嶈鑹插垽鏂槸绠$悊浜哄憳杩樻槸鏅�氱敤鎴凤紙姝e父鏉ヨ鍙湁鏅�氱敤鎴锋墠浼氱敤鍒拌鏌ヨ鎺ュ彛锛�
+		Map<String, List<RoleRightVO>> roleRightMap = uiManagerServiceI.getRoleRightMap(null);
+		// 2銆佹寜鐓у綋鍓嶇櫥褰曠敤鎴锋煡璇㈡潈闄愶紙鍔熻兘鏉冮檺鍜孶I鎺堟潈鐨勬巿鏉冧俊鎭兘鏄斁鍦ㄥ悓涓�寮犺〃閲岀殑锛�
+		// 3銆佹壘鍑哄綋鍓嶈鏌ヨ鐨刄I涓婁笅鏂�
 		PLUILayout context = null;
 		for (int i = 0; i < obj.length; i++) {
 			if (obj[i].plCode.equals(id)) {
@@ -1561,8 +1660,9 @@
 				break;
 			}
 		}
-		return UIContentDO2VO(context,true);
-//		return UIContentDO2VO(null,true);
+		// 4銆佹瘡涓�涓彍鍗曟煡璇㈢殑閮芥槸涓�涓猆I涓婁笅鏂囷紝鎵�浠I涓婁笅鏂囨槸鏈夊姛鑳芥巿鏉冩帶鍒剁殑锛屽彧闇�瑕佹帶鍒跺悗闈㈢殑椤电銆侀〉闈€�佹寜閽殑鏉冮檺銆�
+		return UIContentDO2VO(context, true,roleRightMap);
 	}
+
 }
 

--
Gitblit v1.9.3