dangsn
2024-06-05 f29ad099c6dc5c55d6cb94fb190d06743777ec6d
Source/platformProject/vci-platform-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java
@@ -1,9 +1,20 @@
package com.vci.web.service.impl;
import com.vci.client.omd.linktype.util.Tool;
import com.vci.client.omd.provider.BtmProvider;
import com.vci.client.omd.provider.LinkTypeProvider;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.atm.AttributeDef;
import com.vci.corba.omd.btm.BTMServicePrx;
import com.vci.corba.omd.btm.BizType;
import com.vci.corba.omd.etm.EnumItem;
import com.vci.corba.omd.etm.EnumType;
import com.vci.corba.omd.lcm.Bound;
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.corba.omd.lcm.TransitionVO;
import com.vci.corba.omd.lcm.TransitionVOEvent;
import com.vci.corba.omd.ltm.LinkType;
import com.vci.corba.omd.stm.StatePool;
import com.vci.starter.poi.bo.WriteExcelData;
import com.vci.starter.poi.bo.WriteExcelOption;
import com.vci.starter.poi.util.ExcelUtil;
@@ -30,12 +41,15 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import com.vci.corba.omd.etm.EnumItem;
import plm.ddlTool.client.DDLToolClient;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static com.vci.client.omd.attribpool.ui.VTDataTypePanel.*;
/**
@@ -246,7 +260,7 @@
        List<LifeCycle> unExistLifeCycleList = new ArrayList<LifeCycle>();
        List<LifeCycle> editLifeCycleList = new ArrayList<LifeCycle>();
        String userId = WebUtil.getCurrentUserId();
        String now = VciDateUtil.getNowString(VciDateUtil.DateTimeFormat);
        long now = VciDateUtil.getTime(VciDateUtil.getNow());
        //循环分析需要添加还是修改
        for(OsLifeCycleDTO lifeCycleDTO : lifeCycleDTOList){
            String lifeCycleId = lifeCycleDTO.getId().toLowerCase().trim();
@@ -257,8 +271,8 @@
                lifeCyle.oid = "";
                lifeCyle.id = "";
                lifeCyle.creator = userId;
                lifeCyle.createTime = System.currentTimeMillis();
                lifeCyle.ts = now;
                lifeCyle.createTime = now;
                lifeCyle.ts = VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat);
                lifeCyle.name = lifeCycleDTO.getId();
            }else {
                lifeCyle = lifeCycleService.lifeCycleVO2DO( allLifeCycleLowMap.get(lifeCycleId));
@@ -268,7 +282,7 @@
            lifeCyle.description = lifeCycleDTO.getDescription() == null?"":lifeCycleDTO.getDescription();
            lifeCyle.startState = lifeCycleDTO.getStartStatus() == null?"":lifeCycleDTO.getStartStatus();
            lifeCyle.modifier = userId;
            lifeCyle.modifyTime = System.currentTimeMillis();
            lifeCyle.modifyTime = now;
            //找区域
            List<OsLifeCycleLineDTO> lineDTOList = lifeCycleDTO.getLineDTOList();
            if(CollectionUtils.isEmpty(lineDTOList)){
@@ -362,28 +376,28 @@
    private void importAttributes(Collection<OsAttributeDTO> attributeDTOList) throws VciBaseException {
        Set<String> existAttributeList = attrService.selectAllAttributeMap().keySet();
        Map<String, OsAttributeVO> allAttributeMap = attrService.selectAllAttributeMap();
        List<AttribItem> unExistAttrList = new ArrayList<AttribItem>();
        List<AttribItem> editAttrList = new ArrayList<AttribItem>();
        List<AttributeDef> unExistAttrList = new ArrayList<AttributeDef>();
        List<AttributeDef> editAttrList = new ArrayList<AttributeDef>();
        String userId = WebUtil.getCurrentUserId();
        String now = VciDateUtil.getNowString(VciDateUtil.DateTimeFormat);
        long now = VciDateUtil.getTime(VciDateUtil.getNow());
        //循环分析需要添加还是修改
        for (OsAttributeDTO attributeDTO : attributeDTOList) {
            String attrId = attributeDTO.getId().toLowerCase().trim();
            AttribItem attribItem = null;
            AttributeDef attribItem = null;
            boolean edit = false;
            if (!existAttributeList.contains(attrId)) {
                attribItem = new AttribItem();
                attribItem = new AttributeDef();
                attribItem.oid = "";
                attribItem.ts = now;
                attribItem.ts = VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat);
                attribItem.creator = userId;
                attribItem.createTime = now;
            }else {
                OsAttributeVO attributeVO = allAttributeMap.get(attrId);
                attribItem =new AttribItem();
                attribItem =new AttributeDef();
                attribItem.oid = attributeVO.getOid();
                attribItem.ts = VciDateUtil.date2Str(attributeVO.getTs(),VciDateUtil.DateTimeMillFormat);
                attribItem.creator = attributeVO.getCreator();
                attribItem.createTime = VciDateUtil.date2Str(attributeVO.getCreateTime(),VciDateUtil.DateTimeFormat);
                attribItem.createTime = VciDateUtil.getTime(attributeVO.getCreateTime());
                edit = true;
            }
            attribItem.modifier = userId;
@@ -562,16 +576,16 @@
        //查询已经存在的业务类型
        Map<String, OsBtmTypeVO> allBtmMap = btmService.selectAllBtmMap();
        Set<String> exitBtmList = allBtmMap.keySet();
        List<BtmItem> unExistBtmList = new ArrayList<BtmItem>();
        List<BtmItem> editBtmList = new ArrayList<BtmItem>();
        List<BizType> unExistBtmList = new ArrayList<BizType>();
        List<BizType> editBtmList = new ArrayList<BizType>();
        String userId = WebUtil.getCurrentUserId();
        String now = VciDateUtil.getNowString(VciDateUtil.DateTimeFormat);
        long now = VciDateUtil.getTime(VciDateUtil.getNow());
        for (OsBtmTypeDTO btmTypeDTO : btmTypeDTOList) {
            String btmId = btmTypeDTO.getId().toLowerCase().trim();
            if (!exitBtmList.contains(btmId)) {
                //老平台的内容中,实际不关心关联的数据是否真实存在,所以直接添加就行
                BtmItem btmItem = new BtmItem();
                BizType btmItem = new BizType();
                btmItem.oid = "";
                btmItem.ts = now;
                btmItem.creator = userId;
@@ -582,16 +596,16 @@
                wrapperBtmItem(btmItem,btmTypeDTO);
                unExistBtmList.add(btmItem);
            } else {
                BtmItem btmItem = new BtmItem();
                BizType btmItem = new BizType();
                OsBtmTypeVO btmTypeVO = allBtmMap.get(btmId);
                btmItem.name = btmTypeDTO.getId().toLowerCase();
                btmItem.oid = btmTypeVO.getOid();
                btmItem.creator = btmTypeVO.getCreator();
                btmItem.createTime = VciDateUtil.date2Str(btmTypeVO.getCreateTime(),VciDateUtil.DateTimeFormat);
                btmItem.createTime = VciDateUtil.getTime(btmTypeVO.getCreateTime());
                //修改
                btmItem.modifier = userId;
                btmItem.modifyTime = now;
                btmItem.ts = VciDateUtil.date2Str(btmTypeVO.getTs(),VciDateUtil.DateTimeMillFormat);
                btmItem.ts = VciDateUtil.getTime(btmTypeVO.getTs());
                wrapperBtmItem(btmItem,btmTypeDTO);
                editBtmList.add(btmItem);
            }
@@ -608,16 +622,16 @@
     * @param btmItems 业务类型的对象
     */
    @Override
    public void batchAddBtm(Collection<BtmItem> btmItems){
    public void batchAddBtm(Collection<BizType> btmItems){
        if(!CollectionUtils.isEmpty(btmItems)){
            Map<String, OsAttributeVO> attributeMap = attrService.selectAllAttributeMap();
            for(BtmItem btmItem : btmItems){
                BTMServiceOperations btmService = platformClientUtil.getBtmService();
            for(BizType btmItem : btmItems){
                try{
                    btmService.addBtmItem(btmItem);
                    BTMServicePrx btmService = platformClientUtil.getBtmService();
                    btmService.addBizType(btmItem);
                    //执行完成了需要创建表
                    //获取的时候不一定刷新了缓存,这样就获取不到信息
                    String btmTableName = BtmProvider.getInstance().getBTMTableName(btmItem.name);
                    String btmTableName = BtmProvider.getInstance().getBTTableName(btmItem.name);
                    String sql = "create Table " + btmTableName + "(" + "\n\tOID VARCHAR2(36) not null,\n\tREVISIONOID VARCHAR2(36),\n\tNAMEOID VARCHAR2(36),\n\tBtmName VARCHAR2(36),\n\tISLastR CHAR(1),\n\tISFirstR CHAR(1),\n\tISLastV CHAR(1),\n\tISFirstV CHAR(1),\n\tCreator VARCHAR2(36),\n\tCreateTime TIMESTAMP,\n\tLastModifier VARCHAR2(36),\n\tLastModifyTime TIMESTAMP,\n\tRevisionRule VARCHAR2(36),\n\tVersionRule VARCHAR2(36),\n\tRevisionSeq NUMBER,\n\tRevisionValue VARCHAR2(10),\n\tVersionSeq NUMBER,\n\tVersionValue VARCHAR2(10),\n\tLCTID VARCHAR2(36),\n\tLCStatus VARCHAR2(36),\n\tTS TIMESTAMP,\n\tID VARCHAR2(36),\n\tNAME VARCHAR2(128),\n\tDESCRIPTION VARCHAR2(255),\n\tOWNER VARCHAR2(36),\n\tCHECKINBY VARCHAR2(36),\n\tCHECKINTIME TIMESTAMP,\n\tCHECKOUTBY VARCHAR2(36),\n\tCHECKOUTTIME TIMESTAMP,\n\tCOPYFROMVERSION VARCHAR2(36),\n\t";
                    String[] apNameArray = btmItem.apNameArray;
                    if(apNameArray!=null && apNameArray.length>0){
@@ -636,7 +650,7 @@
                    sql = sql + "\n)";
                    DDLToolClient.getService().executeUpdateOracle(sql);
                    DDLToolClient.getService().executeUpdateOracle(alterSql);
                }catch (VCIError vciError){
                }catch (PLException vciError){
                    throw WebUtil.getVciBaseException(vciError);
                }
            }
@@ -648,10 +662,10 @@
     * @param btmItems 业务类型的对象
     */
    @Override
    public void batchEditBtm(Collection<BtmItem> btmItems){
    public void batchEditBtm(Collection<BizType> btmItems){
        Map<String, OsBtmTypeVO> btmTypeVOMap = btmService.selectAllBtmMap();
        if(!CollectionUtils.isEmpty(btmItems)){
            for(BtmItem btmItem : btmItems){
            for(BizType btmItem : btmItems){
                String btmId = btmItem.name;
                List<String> addAttrList = new ArrayList<String>();
                //修改这里判断不了,是靠属性整体调整的
@@ -674,8 +688,8 @@
                    }
                }
                try{
                    platformClientUtil.getBtmService().updateBtmItem(btmItem);
                }catch (VCIError vciError){
                    platformClientUtil.getBtmService().updateBizType(btmItem);
                }catch (PLException vciError){
                    throw WebUtil.getVciBaseException(vciError);
                }
                addAttrToDB(addAttrList,btmId,false);
@@ -1108,11 +1122,11 @@
     */
    private void addAttrToDB(Collection<String> addedAbList,String btmType,boolean linkType){
        if (!CollectionUtils.isEmpty(addedAbList)) {
            String tableName = linkType?LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTMTableName(btmType);
            String tableName = linkType? LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTTableName(btmType);
            String addSql = "alter table " + tableName + " add(";
            Map<String, OsAttributeVO> attributeMap = attrService.selectAllAttributeMap();
            for (String abName : addedAbList) {
                AttribItem abItem = attrService.attributeVO2DO(attributeMap.get(abName));
                AttributeDef abItem = attrService.attributeVO2DO(attributeMap.get(abName));
                addSql = addSql + Tool.getInstance().getAbSql(abItem);
            }
            addSql = VciBaseUtil.removeComma(addSql.replace("\n\t",""));
@@ -1128,7 +1142,7 @@
     */
    private void removeAttrToDB(Collection<String> removeAbList,String btmType,boolean linkType){
        if (!CollectionUtils.isEmpty(removeAbList)) {
            String tableName = linkType?LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTMTableName(btmType);
            String tableName = linkType?LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTTableName(btmType);
            String removeSql = "alter table " + tableName + " drop(";
            for (String abName : removeAbList) {
                removeSql = removeSql + abName + ",";
@@ -1148,7 +1162,7 @@
     * @param btmItem 业务类型的对象
     * @param btmTypeDTO 业务类型的数据传输对象
     */
    private void wrapperBtmItem(BtmItem btmItem ,OsBtmTypeDTO btmTypeDTO){
    private void wrapperBtmItem(BizType btmItem ,OsBtmTypeDTO btmTypeDTO){
        btmItem.label = btmTypeDTO.getName();
        btmItem.description = btmTypeDTO.getDescription() == null ? "" : btmTypeDTO.getDescription();
        btmItem.isAbstract = false;
@@ -1161,7 +1175,7 @@
        if (StringUtils.isBlank(btmTypeDTO.getRevisionRuleId())) {
            btmItem.revLevel = 0;
        } else {
            btmItem.revLevel = (StringUtils.isNotBlank(btmTypeDTO.getVersionRule()) && VciBtmType.VciBtmTypeVersionRule.NONE.getValue().equalsIgnoreCase(btmTypeDTO.getVersionRule())) ? 1 : 2;
            btmItem.revLevel = (StringUtils.isNotBlank(btmTypeDTO.getVersionRule()) && VciBtmType.VciBtmTypeVersionRule.NONE.getValue().equalsIgnoreCase(btmTypeDTO.getVersionRule())) ? (short) 1 : (short)2;
        }
        btmItem.revInput = btmTypeDTO.isInputRevisionFlag();
        btmItem.revRuleName = btmTypeDTO.getRevisionRuleId()==null?"":btmTypeDTO.getRevisionRuleId();
@@ -1194,7 +1208,7 @@
        List<LinkType> addLinkTypeList = new ArrayList<LinkType>();
        List<LinkType> editLinkTypeList = new ArrayList<LinkType>();
        String userId = WebUtil.getCurrentUserId();
        String now = VciDateUtil.getNowString(VciDateUtil.DateTimeFormat);
        long now = VciDateUtil.getTime(VciDateUtil.getNow());
        for(OsLinkTypeDTO linkTypeDTO : linkTypeDTOS){
            String linkId = linkTypeDTO.getId().toLowerCase().trim();
            LinkType linkType = null;
@@ -1210,8 +1224,8 @@
                OsLinkTypeVO linkTypeVO = allLinkMap.get(linkId);
                linkType.oid = linkTypeVO.getOid();
                linkType.creator = linkTypeVO.getCreator();
                linkType.createTime = VciDateUtil.date2Str(linkTypeVO.getCreateTime(),VciDateUtil.DateTimeFormat);
                linkType.ts = VciDateUtil.date2Str(linkTypeVO.getTs(),VciDateUtil.DateTimeMillFormat);
                linkType.createTime = VciDateUtil.getTime(linkTypeVO.getCreateTime());
                linkType.ts = VciDateUtil.getTime(linkTypeVO.getTs());
                editFlag = true;
            }
            linkType.modifier = userId;
@@ -1273,7 +1287,7 @@
                    sql = sql + "\n)";
                    DDLToolClient.getService().executeUpdateOracle(sql);
                    DDLToolClient.getService().executeUpdateOracle(LinkTypeProvider.getInstance().getAddPKSql(linkType.name));
                }catch (VCIError vciError){
                }catch (PLException vciError){
                    throw WebUtil.getVciBaseException(vciError);
                }
            }
@@ -1314,7 +1328,7 @@
                    addAttrToDB(addAttrList,linkTypeId,true);
                    removeAttrToDB(deleteAttrList,linkTypeId,true);
                }catch (VCIError vciError){
                }catch (PLException vciError){
                    throw WebUtil.getVciBaseException(vciError);
                }
            }