From 99dda6d4254e062f386976e0d66c8379020d3944 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 06 九月 2024 16:34:18 +0800
Subject: [PATCH] 查询模板导出导入
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java | 345 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 335 insertions(+), 10 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 9a1b63a..4dc9c1c 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
@@ -4,19 +4,26 @@
import com.vci.client.mw.ClientContextVariable;
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.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.*;
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.Func;
-import com.vci.web.util.PlatformClientUtil;
-import com.vci.web.util.UITools;
+import com.vci.web.util.*;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -24,10 +31,9 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* UI瀹氫箟鏈嶅姟鐣岄潰鐩稿叧鎺ュ彛
@@ -43,6 +49,18 @@
@Resource
private PlatformClientUtil platformClientUtil;
/**
+ * 瑙掕壊
+ */
+ @Resource
+ private SmRoleQueryServiceI smRoleQueryServiceI;
+
+ /**
+ * 涓氬姟绫诲瀷
+ */
+ @Resource
+ private OsBtmServiceI osBtmServiceI;
+
+ /**
* 鏃ュ織
*/
private Logger logger = LoggerFactory.getLogger(getClass());
@@ -90,6 +108,37 @@
}
/**
+ * 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;
+ }
+
+ /**
* 缁欎笟鍔$被鍨嬩笅娣诲姞ui涓婁笅鏂�
* @param pluiLayout
* @return
@@ -247,6 +296,282 @@
}
/**
+ * 鑾峰彇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;
+ }
+
+ @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();
+ 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.10.0