Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
@@ -6,10 +6,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vci.client.common.oq.OQTool;
import com.vci.client.common.providers.ClientServiceProvider;
import com.vci.client.mw.ClientSessionUtility;
import com.vci.common.qt.object.Condition;
import com.vci.common.qt.object.QueryTemplate;
import com.vci.common.utility.ObjectUtility;
import com.vci.constant.FrameWorkLangCodeConstant;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.atm.AttributeDef;
@@ -21,10 +19,9 @@
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.corba.omd.ltm.LinkType;
import com.vci.corba.omd.stm.StatePool;
import com.vci.corba.omd.tim.TypeIndexDef;
import com.vci.corba.omd.vrm.VersionRule;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.dto.OsBtmTypeDTO;
import com.vci.dto.OsBtmTypeLinkAttributesDTO;
import com.vci.model.IndexObject;
import com.vci.omd.constants.AttributeConstants;
import com.vci.omd.constants.FileObjectType;
@@ -32,14 +29,12 @@
import com.vci.omd.utils.ObjectTool;
import com.vci.pagemodel.*;
import com.vci.po.OsBtmTypePO;
import com.vci.po.OsLinkTypePO;
import com.vci.starter.poi.bo.ReadExcelOption;
import com.vci.starter.poi.bo.WriteExcelData;
import com.vci.starter.poi.bo.WriteExcelOption;
import com.vci.starter.poi.constant.ExcelLangCodeConstant;
import com.vci.starter.poi.util.ExcelUtil;
import com.vci.starter.web.annotation.log.VciUnLog;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.enumpck.BooleanEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseResult;
@@ -47,9 +42,13 @@
import com.vci.starter.web.pagemodel.PageHelper;
import com.vci.starter.web.pagemodel.Tree;
import com.vci.starter.web.util.*;
import com.vci.starter.web.util.BeanUtil;
import com.vci.starter.web.util.Lcm.ConcurrentDateFormat;
import com.vci.starter.web.util.Lcm.DateUtil;
import com.vci.starter.web.util.Lcm.Func;
import com.vci.web.other.AllOsEnumVOMapThreadLocal;
import com.vci.web.service.*;
import com.vci.web.util.*;
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;
@@ -60,7 +59,6 @@
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
@@ -204,10 +202,14 @@
    @Override
    public List<OsBtmTypeVO> btmDO2VOs(Collection<BizType> btmItems,Map<String, OsAttributeVO> attributeVOMap) {
        List<OsBtmTypeVO> VOS = new ArrayList<>();
        Optional.ofNullable(btmItems).orElseGet(() -> new ArrayList<>()).parallelStream().forEach(btmItem -> {
//        Optional.ofNullable(btmItems).orElseGet(() -> new ArrayList<>()).parallelStream().forEach(btmItem -> {
//            OsBtmTypeVO vo = btmDO2VO(btmItem,attributeVOMap);
//            VOS.add(vo);
//        });
        for (BizType btmItem : btmItems) {
            OsBtmTypeVO vo = btmDO2VO(btmItem,attributeVOMap);
            VOS.add(vo);
        });
        }
        return VOS;
    }
@@ -245,6 +247,7 @@
            vo.setTableName(VciBaseUtil.getTableName(vo.getId()));
            vo.setInputRevisionFlag(btmItem.revInput);
            vo.setDelimiter(btmItem.delimiter);
            vo.setImageName(btmItem.imageName);
            vo.setfName(btmItem.fName);
            vo.setVersionRule(String.valueOf(btmItem.verRuleName));
            if (StringUtils.isNotBlank(vo.getRevisionRuleId()) || vo.isInputRevisionFlag()) {
@@ -254,9 +257,10 @@
            vo.setApNameArray(btmItem.apNameArray);
            List<OsAttributeVO> attributeVOS = attributeService.listAttrByIds(Arrays.stream(btmItem.apNameArray).collect(Collectors.toList()),attributeVOMap);
            List<OsBtmTypeAttributeVO> btmTypeAttributeVOS = new ArrayList<>();
            Optional.ofNullable(attributeVOS).orElseGet(() -> new ArrayList<>()).stream().forEach(attributeVO -> {
//            Optional.ofNullable(attributeVOS).orElseGet(() -> new ArrayList<>()).stream().forEach(attributeVO -> {
            for (OsAttributeVO attributeVO : attributeVOS) {
                OsBtmTypeAttributeVO btmTypeAttributeVO = new OsBtmTypeAttributeVO();
                BeanUtil.convert(attributeVO, btmTypeAttributeVO);
                BeanUtilForVCI.convert(attributeVO, btmTypeAttributeVO);
                btmTypeAttributeVO.setPkBtmType(vo.getOid());
                btmTypeAttributeVO.setBtmTypeId(vo.getId());
                btmTypeAttributeVO.setAttributeDataType(attributeVO.getAttributeDataType());
@@ -274,7 +278,8 @@
                    btmTypeAttributeVO.setEnumItemMap(enumService.getEnumValueMap(btmTypeAttributeVO.getEnumId()));
                }
                btmTypeAttributeVOS.add(btmTypeAttributeVO);
            });
//            });
            }
            vo.setAttributes(btmTypeAttributeVOS);
        }
        return vo;
@@ -450,7 +455,7 @@
            List<OsBtmTypeAttributeVO> finalAttrVOs = attrVOs;
            defaultAttributeVOs.stream().forEach(attr -> {
                OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO();
                BeanUtil.convert(attr, attributeVO);
                BeanUtilForVCI.convert(attr, attributeVO);
                attributeVO.setAttributeDataType(attr.getAttributeDataType());
                attributeVO.setAttributeLength(attr.getAttrLength());
                attributeVO.setReferBtmTypeId(attr.getBtmTypeId());
@@ -459,7 +464,8 @@
            });
            attrVOs = finalAttrVOs;
        }
        return attrVOs;
        // TODO: 2024/12/2 Ludc 返回值排序
        return attrVOs.stream().sorted(Comparator.comparing(o->o.getId(),String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList());
    }
    /**
@@ -512,7 +518,7 @@
                throw new PLException("500", new String[]{erreMsg});
            }
        }
        return false;
        return true;
    }
    /**
@@ -581,9 +587,10 @@
            tree.setOid(bizType.oid);
            tree.setLeaf(true);
            tree.setParentName(bizType.fName);
            tree.setIcon(bizType.imageName);
            Map<String, String> atrrMap = new HashMap<>();
            atrrMap.put("name", bizType.name);
            atrrMap.put("lable", bizType.label);
            atrrMap.put("label", bizType.label);
            tree.setAttributes(atrrMap);
            trees.add(tree);
        });
@@ -705,7 +712,13 @@
        List<Tree> rootTreeList = new ArrayList<>();
        BizType[] bizTypes = getBizTypes("");
        OsBtmTypeVO osBtmTypeVO = null;
        List<OsBtmTypeVO> osBtmTypeVOS = btmDO2VOs(Arrays.asList(bizTypes),null);
        Map<String, OsAttributeVO> attributeVOMap = null;
        if(bizTypes.length > 0){
            //先将所需要的属性、枚举数据全部加载出来,避免后续进行重复加载
            attributeVOMap = attributeService.selectAllAttributeMap();
            AllOsEnumVOMapThreadLocal.set(enumService.selectAllEnumMap());
        }
        List<OsBtmTypeVO> osBtmTypeVOS = btmDO2VOs(Arrays.asList(bizTypes),attributeVOMap);
        for (int i = 0; i < osBtmTypeVOS.size(); i++) {
            osBtmTypeVO = osBtmTypeVOS.get(i);
@@ -715,6 +728,7 @@
                tree.setParentName(null);
                tree.setParentId(null);
                tree.setLeaf(true);
                tree.setIcon(osBtmTypeVO.getImageName());
                tree.setId(osBtmTypeVO.getId());
                tree.setText(osBtmTypeVO.getDescription());
                tree.setAttributes(WebUtil.objectToMapString(osBtmTypeVO));
@@ -722,7 +736,8 @@
                rootTreeList.add(tree);
            }
        }
        AllOsEnumVOMapThreadLocal.remove();
        rootTreeList = rootTreeList.stream().sorted((o1, o2) -> o1.getId().compareTo(o2.getId())).collect(Collectors.toList());
        return rootTreeList;
    }
@@ -811,6 +826,7 @@
        bizType.label = dto.getName();
        bizType.fName = dto.getfName();
        bizType.implClass = dto.getImplClass();
        bizType.imageName = dto.getImageName();
        bizType.shape = "";
        bizType.lifeCycle = dto.getLifeCycleId();
        List<String> lcList = Arrays.asList(dto.getSubLifeCycleId().split(","));
@@ -823,14 +839,9 @@
        bizType.revLevel = dto.getRevLevel();
        bizType.revRuleName = dto.getRevisionRuleId();
        bizType.revInput = dto.isInputRevisionFlag();
        bizType.delimiter = (dto.getDelimiter() == null ? "" : dto.getDelimiter());
        bizType.verRuleName = Func.isBlank(dto.getVersionRule()) ? 0 : Short.parseShort(dto.getVersionRule());
        //bizType.imageName = dto.get;
        //List<String> attrIdList = dto.getAttributesDTOList().stream().map(OsBtmTypeLinkAttributesDTO::getId).collect(Collectors.toList());
        bizType.apNameArray = dto.getApNameArray().split(",");//attrIdList.toArray(new String[attrIdList.size()]);
        String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
        long timeMillis = System.currentTimeMillis();
@@ -994,7 +1005,7 @@
                //业务类型已有实例, 只能删除没有数据的列
                if (unRemovableFields != null && unRemovableFields.length > 0) {
                    //移除了不可修改的属性直接报错,就不往下执行了
                    throw new VciBaseException("业务类型已有实例, 只能删除没有数据的列");
                    throw new VciBaseException("业务类型已有实例, 只能删除没有数据的列,有数据的列名为:" + removableFields);
                    /*unRemovableFields_ = Arrays.asList(unRemovableFields);
                    for (int i = 0; i < removableFields.size(); i++) {
                        String abName = removableFields.get(i);
@@ -1275,29 +1286,18 @@
        if (Func.isEmpty(conditionMap)) {
            return new ArrayList<>();
        }
        List<String> indexNameList = new ArrayList<String>();
        QueryTemplate qtl = new QueryTemplate();
        List<String> list = new ArrayList<String>();
        list.add("*");
        qtl.setBtmType("indexobject");
        qtl.setClauseList(list);
        qtl.setId("p");
        qtl.setType("btm");
        qtl.setRightFlag(false);
        Condition condition = OQTool.getCondition(conditionMap);
        qtl.setCondition(condition);
        //HashMap<String, String> indexmap = new HashMap<String, String>();
        BusinessObject findBTMObjects[] = platformClientUtil.getQueryService().findBTMObjects(qtl.getId(), OQTool.qtTOXMl(qtl).asXML());
        List<IndexObject> indexObjects = new ArrayList<>();
        for (int i = 0; i < findBTMObjects.length; i++) {
            BusinessObject findBTMObject = findBTMObjects[i];
        TypeIndexDef[] typenames = ClientServiceProvider.getOMDService().getTypeIndexService().getBTIndexDefs(conditionMap.get("typename"));
        for (int i = 0; i < typenames.length; i++) {
            TypeIndexDef typename = typenames[i];
            IndexObject indexObject = new IndexObject();
            indexObject.setOid(findBTMObject.oid);
            indexObject.setDescription(findBTMObject.description);
            indexObject.setCreateTime(Func.format(new Date(findBTMObject.createTime), DateUtil.PATTERN_DATE));
            indexObject.setIndexName(ObjectTool.getBOAttributeValue(findBTMObject, "indexname"));
            indexObject.setTypeName(ObjectTool.getBOAttributeValue(findBTMObject, "typename"));
            indexObject.setAttrNames(ObjectTool.getBOAttributeValue(findBTMObject, "attrname"));
            indexObject.setOid(typename.oid);
            indexObject.setDescription(typename.description);
            indexObject.setCreateTime(Func.format(new Date(typename.createTime), DateUtil.PATTERN_DATE));
            indexObject.setIndexName(typename.name);
            indexObject.setTypeName(typename.typeName);
            indexObject.setAttrNames(typename.attributes);
            indexObjects.add(indexObject);
        }
        return indexObjects;
@@ -1313,11 +1313,8 @@
    @Override
    public boolean delIndex(String btmName, String indexName) throws PLException {
        VciBaseUtil.alertNotNull(btmName, "业务类型名", indexName, "索引名");
        Map<String, String> conditionMap = new HashMap<>();
        conditionMap.put("typename", btmName);
        conditionMap.put("indexname", indexName);
        List<IndexObject> bo2 = getIndexByCondition(conditionMap);
        if (bo2 != null && bo2.size() > 0) {
        TypeIndexDef[] typeIndexDef= ClientServiceProvider.getOMDService().getTypeIndexService().getBTIndexDefs(btmName);
        if( typeIndexDef != null && typeIndexDef.length > 0 ){
            String[] indexAttr = {indexName};
            boolean alterFlag = platformClientUtil.getBtmService().dropIndex(btmName, indexAttr);
@@ -1325,10 +1322,12 @@
            if (!alterFlag) {
                return false;
            }
            for (int i = 0; i < bo2.size(); i++) {
                String oid = bo2.get(i).getOid();
                BusinessObject bo = platformClientUtil.getBOFactoryService().readBusinessObject(oid, "indexobject");
                platformClientUtil.getBOFactoryService().deleteBusinessObject(bo, 1);
            for (int i = 0; i < typeIndexDef.length; i++) {
                if(!typeIndexDef[i].name.equals(indexName)) {
                    continue;
                }
                String oid = typeIndexDef[i].oid;
                ClientServiceProvider.getOMDService().getTypeIndexService().delIndexDef(oid);
            }
        }
        return true;
@@ -1346,49 +1345,50 @@
        String btmName = indexObjectList.get(0).getTypeName();
        String indexNames = indexObjectList.stream().map(IndexObject::getIndexName).collect(Collectors.joining(","));
        String[] oldindexAttr = {indexNames};
        BusinessObject bo;
        List<BusinessObject> boList = new ArrayList<>();
        //先查询当前添加索引是否已经存在,如果存在就先删除再新增实现替换操作
        Map<String, String> conditionMap = new HashMap<>();
        conditionMap.put("typename", btmName);
        //先这样处理,前端现在只做了单次保存,所以不用in
        conditionMap.put("indexname", indexNames);
        List<IndexObject> indexObjects = getIndexByCondition(conditionMap);
        if (indexObjects != null && indexObjects.size() > 0) {
            //索引不存在时删除就会报错索引不存在,所以这里有索引才去删除
            boolean b = platformClientUtil.getBtmService().dropIndex(btmName, oldindexAttr);
            if (b) {
                for (int i = 0; i < indexObjects.size(); i++) {
                    String oid = (String) indexObjects.get(i).getOid();
                    bo = platformClientUtil.getBOFactoryService().readBusinessObject(oid, "indexobject");
                    platformClientUtil.getBOFactoryService().deleteBusinessObject(bo, 1);
                }
            }
        }
//        BusinessObject bo;
//        List<BusinessObject> boList = new ArrayList<>();
//        //先查询当前添加索引是否已经存在,如果存在就先删除再新增实现替换操作
//        Map<String, String> conditionMap = new HashMap<>();
//        conditionMap.put("typename", btmName);
//        //先这样处理,前端现在只做了单次保存,所以不用in
//        conditionMap.put("indexname", indexNames);
        TypeIndexDef[] typeIndexDefs = platformClientUtil.getTypeIndexService().getBTIndexDefs(btmName);
        for (int i = 0; i < indexObjectList.size(); i++) {
            IndexObject indexObject = indexObjectList.get(i);
            //bo = platformClientUtil.getBOFService().initBusinessObject("indexobject");
            bo = boService.createCBOByBtmName("indexobject");
            List<AttributeValue> attributeValues = new ArrayList<>();
            attributeValues.add(new AttributeValue("typename", btmName));
            attributeValues.add(new AttributeValue("indexname", indexObject.getIndexName()));
            attributeValues.add(new AttributeValue("attrname", indexObject.getAttrNames()));
            bo.newAttrValList = attributeValues.toArray(new AttributeValue[attributeValues.size()]);
            bo.description = indexObject.getDescription();
            String[] indexAttr = {indexObject.getIndexName(), indexObject.getAttrNames()};
            //给指定业务类型的指定属性创建索引
            boolean alterFlag = platformClientUtil.getBtmService().addIndex(btmName, indexAttr);
            //索引创建成功之后,需要存储成功索引到索引表中
            if (!alterFlag) {
                return false;
        if(typeIndexDefs!=null && typeIndexDefs.length>0){
            boolean hasIndex = false;
            for(int i = 0; i < typeIndexDefs.length; i ++){
                if(!typeIndexDefs[i].name.equals(indexNames)) {
                    continue;
                }
                String oid = typeIndexDefs[i].oid;
                platformClientUtil.getTypeIndexService().delIndexDef(oid);
                hasIndex = true;
            }
            boList.add(bo);
            //添加索引信息到索引的业务表中
            //platformClientUtil.getBOFactoryService().createBusinessObject(bo,false,false);
            //索引不存在时删除就会报错索引不存在,所以这里有索引才去删除
            if(hasIndex) {
                platformClientUtil.getBtmService().dropIndex(btmName, oldindexAttr);
            }
        }
        //添加索引信息到索引的业务表中
        platformClientUtil.getBOFactoryService().batchCreateBusinessObject(boList.toArray(new BusinessObject[boList.size()]), false, false);
        StringBuilder sb = new StringBuilder();
        List<TypeIndexDef> saveDefs = new ArrayList<>();
        for(int i = 0; i < indexObjectList.size(); i ++){
            TypeIndexDef saveDef = new TypeIndexDef();
            saveDef.typeName = indexObjectList.get(i).getTypeName();
            saveDef.name = indexObjectList.get(i).getIndexName();
            saveDef.description = indexObjectList.get(i).getDescription();
            saveDef.attributes = indexObjectList.get(i).getAttrNames();
            sb.append(indexObjectList.get(i).getAttrNames());
            if(i<indexObjectList.size()-1){
                sb.append(",");
            }
            saveDefs.add(saveDef);
        }
        String[] indexAttr = {indexObjectList.get(0).getIndexName(),sb.toString()};
        boolean alterFlag = platformClientUtil.getBtmService().addIndex(btmName, indexAttr);
        if(!alterFlag) {
            return false;
        }
        ClientServiceProvider.getOMDService().getTypeIndexService().saveIndexDefs(saveDefs.toArray(new TypeIndexDef[saveDefs.size()]));
        return true;
    }
@@ -1406,7 +1406,7 @@
        //设置列名
        List<String> columns = new ArrayList<>(
                Arrays.asList("类型名称", "标签", "继承自", "实现类", "描述", "版本规则", "版本号规则",
                        "是否手工输入", "分隔符", "版次号规则", "生命周期", "备选生命周期列表", "属性列表")
                        "是否手工输入", "分隔符", "版次号规则","图标", "生命周期", "备选生命周期列表", "属性列表")
        );
        try {
            new File(excelPath).createNewFile();
@@ -1430,9 +1430,10 @@
                excelDataList.add(new WriteExcelData(i + 1, 7, bizType.revInput));
                excelDataList.add(new WriteExcelData(i + 1, 8, bizType.delimiter));
                excelDataList.add(new WriteExcelData(i + 1, 9, bizType.verRuleName));
                excelDataList.add(new WriteExcelData(i + 1, 10, bizType.lifeCycle));
                excelDataList.add(new WriteExcelData(i + 1, 11, String.join(",", bizType.lifeCycles)));
                excelDataList.add(new WriteExcelData(i + 1, 12, String.join(",", bizType.apNameArray)));
                excelDataList.add(new WriteExcelData(i + 1, 10, bizType.imageName));
                excelDataList.add(new WriteExcelData(i + 1, 11, bizType.lifeCycle));
                excelDataList.add(new WriteExcelData(i + 1, 12, String.join(",", bizType.lifeCycles)));
                excelDataList.add(new WriteExcelData(i + 1, 13, String.join(",", bizType.apNameArray)));
                attributes.addAll(Arrays.asList(bizType.apNameArray));
                i++;
            }
@@ -1540,7 +1541,7 @@
                excelReapeat.put(osBtmTypePO.getName(), osBtmTypePO.getRowIndex());
                BizType bizType = new BizType();
                bizType.name = osBtmTypePO.getName();
                bizType.label = osBtmTypePO.getLable();
                bizType.label = osBtmTypePO.getLabel();
                bizType.description = osBtmTypePO.getDescription();
                bizType.fName = osBtmTypePO.getFName();
                bizType.implClass = osBtmTypePO.getImplClass();
@@ -1549,6 +1550,7 @@
                bizType.revInput = Boolean.parseBoolean(osBtmTypePO.getRevInput().toLowerCase(Locale.ROOT));
                bizType.delimiter = osBtmTypePO.getDelimiter();
                bizType.verRuleName = osBtmTypePO.getVerRuleName();
                bizType.imageName = osBtmTypePO.getImageName();
                bizType.lifeCycle = osBtmTypePO.getLifeCycle();
                bizType.lifeCycles = osBtmTypePO.getLifeCycles().split(",");
                bizType.apNameArray = osBtmTypePO.getApNameArray().split(",");
@@ -1622,6 +1624,7 @@
                tree.setParentName(parentBIzType.getfName());
                tree.setParentId(parentBIzType.getOid());
                tree.setLeaf(true);
                tree.setIcon(bizType.getImageName());
                tree.setText(bizType.getDescription());
                tree.setAttributes(WebUtil.objectToMapString(bizType));
                tree.setChildren(getChildren(osBtmTypeVOS, bizType));