yuxc
2024-08-06 769e437befb3354c1113ca5b5c2b8240995078be
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
@@ -1,20 +1,27 @@
package com.vci.web.service.impl;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.atm.AttributeDef;
import com.vci.corba.omd.btm.BizType;
import com.vci.corba.omd.ltm.LinkType;
import com.vci.corba.omd.qtm.QTD;
import com.vci.omd.constants.AttributeConstants;
import com.vci.pagemodel.*;
import com.vci.starter.web.annotation.log.VciUnLog;
import com.vci.starter.web.enumpck.BooleanEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.pagemodel.PageHelper;
import com.vci.starter.web.pagemodel.Tree;
import com.vci.starter.web.util.BeanUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.util.VciDateUtil;
import com.vci.web.pageModel.*;
import com.vci.web.service.*;
import com.vci.web.util.ConcurrentDateFormat;
import com.vci.web.util.Func;
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,6 +30,8 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -336,6 +345,88 @@
    }
    /**
     * 修改业务类型中对应属性名的属性
     * @param apName
     * @return
     * @throws PLException
     */
    @Override
    public boolean alterAp(String apName) throws PLException {
        String[] btmNames = null;
        List<String> btmNameList = new ArrayList<String>();
        AttributeDef abItem = null;
        try {
            abItem = platformClientUtil.getAttributeService().getAttributeDefByName(apName);
        } catch (PLException e1) {
            e1.printStackTrace();
        }
        if(abItem == null || abItem.equals("")){
            return true;
        }
        try {
            btmNames = platformClientUtil.getBtmService().getBTNamesByAPName(apName);
        } catch (PLException e) {
            e.printStackTrace();
        }
        if(btmNames == null || btmNames.length <= 0){
            return true;
        }
        btmNameList = Arrays.asList(btmNames);
        for(Iterator<String> i = btmNameList.iterator(); i.hasNext();){
            String btmName = i.next();
            try {
                platformClientUtil.getBtmService().modifyBTAttribute(btmName, apName);
            } catch (PLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                String erreMsg = "调整业务类型中【"+apName+"】属性时出现错误,原因:"+e.getMessage();
                logger.error(erreMsg);
                throw new PLException("500",new String[]{erreMsg});
            }
        }
        return false;
    }
    /**
     * 判断该属性是否已经在业务类型中产生了数据
     * @param abName
     * @return
     * @throws PLException
     */
    @Override
    public boolean hasInstance(String abName) throws PLException {
        String[] btmNames = platformClientUtil.getBtmService().getBTNamesByAPName(abName);
        if(btmNames == null || btmNames.length == 0){
            return false;
        }
        for(int i = 0; i < btmNames.length; i++){
            String btmName = btmNames[i];
            boolean flag;
            flag = platformClientUtil.getBtmService().hasData(btmName);
            if(flag){
                return flag;
            }
        }
        return false;
    }
    /**
     * 获取名字以filter开始的业务类型(for 查询),主要用于属性池的业务类型选择对话框
     * 获取全部业务类型,传参filter为""
     * @param btmName
     * @return
     * @throws PLException
     */
    @Override
    public BizType[] getBizTypes(String btmName) throws PLException {
        if(null == btmName){
            btmName = "";
        }
        return platformClientUtil.getBtmService().getBizTypes(btmName);
    }
    /**
     * 参照业务类型
     *
     * @param conditionMap 查询条件
@@ -438,6 +529,109 @@
        ervo.setTabRelViewList(relationVOList);
        return ervo;
    }
    /**
     * 获取所有业务类型(树形结构)
     * @return 查询结果
     */
    @Override
    public BaseResult<List<Tree>> getTreeBizTypes() throws PLException {
        List<Tree> rootTreeList = new ArrayList<>();
        BizType[] bizTypes = getBizTypes("");
        BizType btItem = null;
        for(int i = 0; i < bizTypes.length; i++){
            btItem = bizTypes[i];
            if(btItem.fName.equals("")){
                Tree tree = new Tree();
                tree.setOid(btItem.oid);
                tree.setParentName(null);
                tree.setParentId(null);
                tree.setLeaf(true);
                tree.setText(btItem.description);
                tree.setAttributes(WebUtil.objectToMapString(btItem));
                tree.setChildren(getChildren(bizTypes,btItem));
                rootTreeList.add(tree);
            }
        }
        return BaseResult.success(rootTreeList);
    }
    /**
     * 获取业务全部属性类型
     * @param btmName 业务类型名称
     * @return 属性的信息
     */
    @Override
    public List<OsBtmTypeAttributeVO> getBizTypeQTDs(String btmName) throws PLException, ParseException {
        VciBaseUtil.alertNotNull(btmName, "业务类型编号");
        List<OsBtmTypeAttributeVO> osBtms = new ArrayList<>();
        //查询系统默认属性
        Map<String, AttributeDef> collect = Arrays.stream(platformClientUtil.getBtmService().getSysAttributeDefs())
                .collect(Collectors.toMap(str -> str.name, str -> str));
        for (String attrName : platformClientUtil.getBtmService().getSysAttributeNames()) {
            AttributeDef sysAttributeDef = collect.get(attrName.toLowerCase());
            OsBtmTypeAttributeVO vo = new OsBtmTypeAttributeVO();
            vo.setOid(sysAttributeDef.oid);
            vo.setAttrDataType(sysAttributeDef.vtDataType);
            vo.setPkBtmType(btmName);
            vo.setCreateTime(new Date(sysAttributeDef.createTime));
            vo.setCreator(sysAttributeDef.creator);
            vo.setDefaultValue(sysAttributeDef.defValue);
            vo.setDescription(sysAttributeDef.description);
            vo.setRange(sysAttributeDef.rage);
            vo.setId(attrName);
            vo.setName(sysAttributeDef.label);
            vo.setLastModifier(sysAttributeDef.modifier);
            vo.setLastModifyTime(new Date(sysAttributeDef.modifyTime));
            osBtms.add(vo);
        }
        //查询业务类型下的属性
        AttributeDef[] attributeDefs = platformClientUtil.getBtmService().getAttributeDefs(btmName);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (AttributeDef attribute : attributeDefs) {
            OsBtmTypeAttributeVO vo = new OsBtmTypeAttributeVO();
            vo.setOid(attribute.oid);
            vo.setAttrDataType(attribute.vtDataType);
            vo.setPkBtmType(btmName);
            vo.setCreateTime(new Date(attribute.createTime));
            vo.setCreator(attribute.creator);
            vo.setDefaultValue(attribute.defValue);
            vo.setDescription(attribute.description);
            vo.setRange(attribute.rage);
            vo.setId(attribute.name);
            vo.setName(attribute.label);
            vo.setTs(formatter.parse(attribute.ts));
            vo.setLastModifier(attribute.modifier);
            vo.setOwner(attribute.creator);
            vo.setLastModifyTime(new Date(attribute.modifyTime));
            String maxLength = AttributeConstants.getOtherValueByType(attribute.other, AttributeConstants.LENGTH);
            if(StringUtils.isNotBlank(maxLength)){
                vo.setAttributeLength(Integer.valueOf(maxLength));
            }
            osBtms.add(vo);
        }
        return osBtms;
    }
    private List<Tree> getChildren(BizType[] bizTypes,BizType parentBIzType){
        List<Tree> trees= new ArrayList<>();
        for (BizType bizType : bizTypes) {
            if(StringUtils.isBlank(bizType.fName)){
                continue;
            }
            if(bizType.fName.equals(parentBIzType.name)){
                Tree tree = new Tree();
                tree.setOid(bizType.oid);
                tree.setParentName(parentBIzType.fName);
                tree.setParentId(parentBIzType.oid);
                tree.setLeaf(true);
                tree.setText(bizType.description);
                tree.setAttributes(WebUtil.objectToMapString(bizType));
                tree.setChildren(getChildren(bizTypes,bizType));
                trees.add(tree);
            }
        }
        return trees;
    }
    /**
     * 将业务类型拼接json