yuxc
2024-06-24 841588bc33c7ab2f547b046ada0d91bc4be67ade
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java
@@ -4,17 +4,14 @@
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.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.pagemodel.SessionInfo;
import com.vci.starter.web.util.*;
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;
@@ -33,9 +30,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,7 +37,6 @@
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;
/**
@@ -136,8 +129,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 +153,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 +167,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));
   }
@@ -404,7 +395,6 @@
    * @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;
@@ -412,7 +402,7 @@
      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);
         }
@@ -450,12 +440,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);
      }
@@ -531,7 +520,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);
         }
@@ -724,7 +713,6 @@
    * @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) {
      if(StringUtils.isBlank(btmId) || StringUtils.isBlank(id)){
         return null;
@@ -732,7 +720,7 @@
      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);
         }
@@ -773,8 +761,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 +773,6 @@
    * @return 显示对象,key是action的主键
    */
   @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 +829,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 +840,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()));
@@ -1024,7 +1002,7 @@
    */
   private List<UILayoutVO> listLayoutByContent(String pkContent){
      try {
         return UILayoutDO2VOs(Arrays.stream(ServiceProvider.getUIService().getPLTabPagesByPageDefinationOId(pkContent)).collect(Collectors.toList()),true);
         return UILayoutDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(pkContent)).collect(Collectors.toList()),true);
      } catch (PLException vciError) {
         throw WebUtil.getVciBaseException(vciError);
      }
@@ -1067,7 +1045,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);
@@ -1148,8 +1125,7 @@
         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));
               layoutVO.setComponentVOs(uiComponentDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(layoutVO.getOid())).collect(Collectors.toList()),true));
            } catch (PLException vciError) {
               throw WebUtil.getVciBaseException(vciError);
            }
@@ -1173,7 +1149,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);
@@ -1196,7 +1171,7 @@
      }
      if(!QUERY_BY_CACHE){
         try {
            return uiComponentDO2VO(ServiceProvider.getUIService().getPLPageDefinationById(componentOid),true);
            return uiComponentDO2VO(platformClientUtil.getUIService().getPLPageDefinationById(componentOid),true);
         } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
         }
@@ -1268,8 +1243,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));
               } catch (PLException vciError) {
                  throw WebUtil.getVciBaseException(vciError);
               }
@@ -1305,7 +1279,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);
               } catch (PLException vciError) {
                  throw WebUtil.getVciBaseException(vciError);
               }
@@ -1356,7 +1330,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);
               }
@@ -1406,7 +1380,32 @@
   @Override
   public List<UIButtonDefineVO> listButtonByComponent(String pkComponent){
      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());
         Map<String,RoleRightInfo> allRightRoleMap = new HashMap<>();
         RoleRightInfo[] bts = platformClientUtil.getFrameworkService().getRoleRightByUserName("bt");
         Map<String,Long> rightMap = new HashMap<String,Long>();
         for(RoleRightInfo obj:bts){
            allRightRoleMap.put(obj.funcId, obj);
            rightMap.put(obj.funcId,obj.rightValue);
         }
         //循环对按钮权限进行判断,没有权限的将移除buttonDefineVOS对象
         Iterator<UIButtonDefineVO> buttonDefineVO = buttonDefineVOS.iterator();
         while (buttonDefineVO.hasNext()){
            UIButtonDefineVO buttonDefine = buttonDefineVO.next();
            if(rightMap.containsKey(buttonDefine.getPkComponent())) {
               Long rightValue = rightMap.get(buttonDefine.getPkComponent());
               int nodeValue = buttonDefine.getOrderNum();
               if (nodeValue >= 0 && nodeValue <= 63) {
                  //进行位与操作,如果相等则表示具有当前操作的权限
                  long preValue = (rightValue >> nodeValue) & 1;
                  if (preValue != 1) {
                     buttonDefineVO.remove();
                  }
               }
            }
         }
         if(CollectionUtils.isEmpty(buttonDefineVOS)){
            return buttonDefineVOS;
         }
@@ -1480,8 +1479,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,15 +1540,11 @@
    * @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) {
      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);
      }
@@ -1562,7 +1556,6 @@
         }
      }
      return UIContentDO2VO(context,true);
//      return UIContentDO2VO(null,true);
   }
}