dangsn
2024-06-05 72c7bbd66b8456db7dabf0dbc15f7aa9c2af2b9d
Source/platformProject/vci-platform-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java
@@ -1,7 +1,11 @@
package com.vci.web.service.impl;
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.bof.RevisionValueObject;
import com.vci.client.bof.VersionValueObject;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.corba.common.VCIError;
import com.vci.corba.common.PLException;
import com.vci.corba.omd.data.*;
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.file.pagemodel.VciFileObjectVO;
import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus;
@@ -19,10 +23,8 @@
import com.vci.starter.web.util.*;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.dto.*;
import com.vci.web.enumpck.UIComponentTypeEnum;
import com.vci.web.enumpck.UIFieldTypeEnum;
import com.vci.web.enumpck.UITreeLoadTypeEnum;
import com.vci.web.model.BaseLinkModel;
import com.vci.web.pageModel.*;
import com.vci.web.query.UIDataGridQuery;
import com.vci.web.query.UIFormQuery;
@@ -35,9 +37,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import plm.bs.bom.clientobject.*;
import plm.bs.bom.common.*;
import plm.corba.qt.BOAndLO;
import java.lang.reflect.Method;
import java.util.*;
@@ -1070,11 +1069,12 @@
        com.vci.client.bof.ClientBusinessObject afterCBO = null;
        try {
//            BusinessObject resultBO = platformClientUtil.getBOFactoryService().createBusinessObject(resultCbo.getObj().getBusinessObject(),false,false);
            com.vci.corba.omd.data.BusinessObject resultBO = ServiceProvider.getBOFService().createBusinessObject(resultCbo.getObj().getBusinessObject(),false,false);
//            BusinessObject resultBO = ServiceProvider.getBOFService().createBusinessObject(resultCbo.getObj().getBusinessObject(),false,false);
            BusinessObject resultBO = ServiceProvider.getBOFService().createBusinessObject(resultCbo.getObj().getBusinessObject(),false,false);
            afterCBO = new com.vci.client.bof.ClientBusinessObject();
            afterCBO.setBusinessObject(resultBO);
            result.setObj(boService.cbo2Map(afterCBO));
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){
@@ -1089,7 +1089,7 @@
            try {
//                platformClientUtil.getBOFactoryService().deleteBusinessObject(afterCBO.getBusinessObject(),1);
                ServiceProvider.getBOFService().deleteBusinessObject(afterCBO.getBusinessObject(),1);
            } catch (VCIError vciError) {
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e);
@@ -1135,7 +1135,7 @@
        Map<String,String> baseDataMap = formDataDTO2MapLow(formDataDTO);
        Map<String,String> allDataMapLow = new HashMap<>();
        allDataMapLow.putAll(dataLow);
        allDataMapLow.putAll(baseDataMap);
//        allDataMapLow.putAll(baseDataMap);
        //判断必输项
        BaseResult result = checkRequired(formDefineVO,null,allDataMapLow);
        if(!result.isSuccess()){
@@ -1246,7 +1246,7 @@
                baseModel.setRevisionValue("");
            }
            return  changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextRevisionValueObject(WebUtil.getTableName(btmTypeVO.getId()),baseModel.getNameOid(),btmTypeVO.getRevisionRuleId(),btmTypeVO.isInputRevisionFlag(),baseModel.getRevisionValue()));
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
    }
@@ -1270,10 +1270,10 @@
     * @return 版本的值对象
     */
    @Override
    public VersionValueObject getNextVersion(OsBtmTypeVO btmTypeVO,BaseModel baseModel){
    public VersionValueObject getNextVersion(OsBtmTypeVO btmTypeVO, BaseModel baseModel){
        try{
            return changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextVersionValue(WebUtil.getTableName(btmTypeVO.getId()),baseModel.getRevisionOid(),baseModel.getNameOid(),WebUtil.getInt(btmTypeVO.getVersionRule())));
        }catch (VCIError vciError){
        }catch (PLException vciError){
            throw WebUtil.getVciBaseException(vciError);
        }
    }
@@ -1329,8 +1329,8 @@
            return beforeResult;
        }
        //封装数据
        List<com.vci.corba.omd.data.BusinessObject> addBos = new ArrayList<>();
        List<com.vci.corba.omd.data.BusinessObject> afterBOs = new ArrayList<>();
        List<BusinessObject> addBos = new ArrayList<>();
        List<BusinessObject> afterBOs = new ArrayList<>();
        List<com.vci.client.bof.ClientBusinessObject> afterCBOs = new ArrayList<>();
        Map<String,List<String>> releasedFileOids = new HashMap<>();
        for(FormDataDTO formDataDTO:formDataDTOList.getFormDataDTOS()) {
@@ -1345,15 +1345,15 @@
            }
        }
        try {
//            com.vci.corba.omd.data.BusinessObject[] resultBOs = platformClientUtil.getBOFactoryService().batchCreateBusinessObject(addBos.toArray(new BusinessObject[0]), false, false);
            com.vci.corba.omd.data.BusinessObject[] resultBOs = ServiceProvider.getBOFService().batchCreateBusinessObject(addBos.toArray(new com.vci.corba.omd.data.BusinessObject[0]), false, false);
//            BusinessObject[] resultBOs = platformClientUtil.getBOFactoryService().batchCreateBusinessObject(addBos.toArray(new BusinessObject[0]), false, false);
            BusinessObject[] resultBOs = ServiceProvider.getBOFService().batchCreateBusinessObject(addBos.toArray(new BusinessObject[0]), false, false);
            afterBOs = Arrays.stream(resultBOs).collect(Collectors.toList());
            Arrays.stream(resultBOs).forEach(bo->{
                com.vci.client.bof.ClientBusinessObject cbo = new com.vci.client.bof.ClientBusinessObject();
                cbo.setBusinessObject(bo);
                afterCBOs.add(cbo);
            });
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(releasedFileOids)){
@@ -1369,7 +1369,7 @@
            //说明后置事件出现了错误,那么就需要删除以前的这条数据
            try {
                platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(afterBOs.toArray(new BusinessObject[0]),1);
            } catch (VCIError vciError) {
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e);
@@ -1409,7 +1409,7 @@
//            platformClientUtil.getBOFactoryService().updateBusinessObject(new BusinessObjectHolder(resultCbo.getObj().getBusinessObject()));
            ServiceProvider.getBOFService().updateBusinessObject(resultCbo.getObj().getBusinessObject());
            result.setObj(boService.cbo2Map(resultCbo.getObj()));
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){
@@ -1453,11 +1453,11 @@
        BaseResult<Map<String,Object>> result = BaseResult.success();
        try {
//            BusinessObject bo = platformClientUtil.getBOFactoryService().createBusinessObject(resultCbo.getObj().getBusinessObject(),formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion());
            com.vci.corba.omd.data.BusinessObject bo = ServiceProvider.getBOFService().createBusinessObject(resultCbo.getObj().getBusinessObject(),formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion());
            BusinessObject bo = ServiceProvider.getBOFService().createBusinessObject(resultCbo.getObj().getBusinessObject(),formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion());
            com.vci.client.bof.ClientBusinessObject afterCbo = new com.vci.client.bof.ClientBusinessObject();
            afterCbo.setBusinessObject(bo);
            result.setObj(boService.cbo2Map(afterCbo));
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){
@@ -1494,7 +1494,7 @@
            return beforeResult;
        }
        //封装数据
        List<com.vci.corba.omd.data.BusinessObject> updateCBOS = new ArrayList<>();
        List<BusinessObject> updateCBOS = new ArrayList<>();
        Map<String,List<String>> releasedFileOids = new HashMap<>();
        List<com.vci.client.bof.ClientBusinessObject> afterCBOs = new ArrayList<>();
        for(FormDataDTO formDataDTO:formDataDTOList.getFormDataDTOS()) {
@@ -1509,8 +1509,8 @@
            }
        }
        try {
            platformClientUtil.getBOFactoryService().batchUpdateBusinessObject(new BusinessObjectListHolder(updateCBOS.toArray(new BusinessObject[0])));
        } catch (VCIError vciError) {
            platformClientUtil.getBOFactoryService().batchUpdateBusinessObject(updateCBOS.toArray(new BusinessObject[updateCBOS.size()]));
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(releasedFileOids)){
@@ -1611,11 +1611,13 @@
        }
        VciBaseUtil.switchCollectionForOracleIn(finalCbo).stream().forEach(cbos->{
            try {
                platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.stream().map(s->s.getBusinessObject()).collect(Collectors.toList()).toArray(new BusinessObject[0]),1);
            } catch (VCIError vciError) {
//                platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.stream().map(s->s.getBusinessObject()).collect(Collectors.toList()).toArray(new BusinessObject[0]),1);
                ServiceProvider.getBOFService().batchDeleteBusinessObject(cbos.stream().map(s->s.getBusinessObject()).collect(Collectors.toList()).toArray(new BusinessObject[0]),1);
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
        });
        System.out.println("zheshi shazi ");
        return BaseResult.success();
    }
@@ -1683,7 +1685,7 @@
        try {
//            fromCbo.setBusinessObject(platformClientUtil.getBOFactoryService().readBusinessObject(fromOid,fromBtmName));
            fromCbo.setBusinessObject(ServiceProvider.getBOFService().readBusinessObject(fromOid,fromBtmName));
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        String finalPrefix = prefix;
@@ -1714,14 +1716,14 @@
            clo.setToBO(toCbo);
        }
        //执行保存
        com.vci.corba.omd.data.BusinessObject[] bos = new com.vci.corba.omd.data.BusinessObject[1];
        BusinessObject[] bos = new BusinessObject[1];
        toCbo.dealBusinessObjectNullValue();
        clo.dealLinkObjectNullValue();
        bos[0] = toCbo.getBusinessObject();
        try {
//            platformClientUtil.getBOFactoryService().createBusinessObjectWithLink(bosHolder,loHolder);
            ServiceProvider.getBOFService().createBusinessObjectWithLink(bos,clo.getLinkObject());
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(formLinkDataDTO.getReleaseFileOids())){
@@ -1738,7 +1740,7 @@
//                platformClientUtil.getBOFactoryService().deleteLinkObject(clo.getLinkObject());
                ServiceProvider.getBOFService().deleteBusinessObject(toCbo.getBusinessObject(),1);
                ServiceProvider.getBOFService().deleteLinkObject(clo.getLinkObject());
            } catch (VCIError vciError) {
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e);
@@ -1770,18 +1772,18 @@
            return result;
        }
        //处理业务类型得到数据
        com.vci.client.bof.ClientLinkObject clo ;
        ClientLinkObject clo ;
        if(editFlag){
            try {
//                LinkObject linkObject = platformClientUtil.getBOFactoryService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType());
                com.vci.corba.omd.data.LinkObject linkObject = ServiceProvider.getBOFService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType());
                clo = new com.vci.client.bof.ClientLinkObject();
                LinkObject linkObject = ServiceProvider.getBOFService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType());
                clo = new ClientLinkObject();
                clo.setLinkObject(linkObject);
            } catch (VCIError vciError) {
            } catch (PLException vciError) {
                throw WebUtil.getVciBaseException(vciError);
            }
        }else{
            clo = new com.vci.client.bof.ClientLinkObject();
            clo = new ClientLinkObject();
            //处理初始化的数据
            clo.setOid(VciBaseUtil.getPk());
            clo.setCreator(VciBaseUtil.getCurrentUserId());
@@ -1939,11 +1941,12 @@
        com.vci.client.bof.ClientBusinessObject cbo = new com.vci.client.bof.ClientBusinessObject();
        String copyfromversion = baseDataMap.get("copyfromversion");
        OsBtmTypeVO btmTypeVO = btmService.getBtmById(btmName);
        List<String> attributeList = btmTypeVO.getAttributes().stream().map(attribute -> attribute.getId()).collect(Collectors.toList());
        if(editFlag || newRevision || newVersion){
            try {
//                cbo.setBusinessObject(platformClientUtil.getBOFactoryService().readBusinessObject(editFlag?oid:copyfromversion,btmName));
                cbo.setBusinessObject(ServiceProvider.getBOFService().readBusinessObject(editFlag?oid:copyfromversion,btmName));
            } catch (VCIError vciError) {
            } catch (PLException vciError) {
                throw new VciBaseException("使用主键在系统中没有查询到数据",new String[]{oid},vciError);
            }
            if(btmTypeVO.isRevisionFlag() && newRevision){
@@ -1975,7 +1978,7 @@
                    LifeCycle lifeCycleVO = null;
                    try {
                        lifeCycleVO = ServiceProvider.getOMDService().getLifeCycleService().getLifeCycle(btmTypeVO.getLifeCycleId());
                    } catch (VCIError e) {
                    } catch (PLException e) {
                        throw new RuntimeException(e);
                    }
                    if(lifeCycleVO == null || StringUtils.isBlank(lifeCycleVO.oid)){
@@ -2001,7 +2004,7 @@
                    LifeCycle lifeCycleVO = null;
                    try {
                        lifeCycleVO = ServiceProvider.getOMDService().getLifeCycleService().getLifeCycle(btmTypeVO.getLifeCycleId());
                    } catch (VCIError e) {
                    } catch (PLException e) {
                        throw new RuntimeException(e);
                    }
                    if(lifeCycleVO == null || StringUtils.isBlank(lifeCycleVO.oid)){
@@ -2068,7 +2071,15 @@
                cbo.setIsFirstV(true);
            }
        }
//        Iterator<Map.Entry<String, String>> iterator = baseDataMap.entrySet().iterator();
//        while(iterator.hasNext()){
//            Map.Entry<String, String> next = iterator.next();
//            if(!attributeList.contains(next.getKey())){
//                iterator.remove();
//            }
//        }
        setValueToCbo(dataLowMap,baseDataMap,cbo,editFlag);
//        cbo.setName(dataLowMap.get("name"));
        return cbo;
    }
@@ -2105,8 +2116,10 @@
                //平台不能传递这个
            }else{
                try {
                    cbo.setAttributeValueWithNoCheck(key, value, !editFlag);
                } catch (VCIError vciError) {
//                    if(!SystemAttribute.bosysAttList().contains(key)){
                        cbo.setAttributeValueWithNoCheck(key, value, !editFlag);
//                    }
                } catch (PLException vciError) {
                    throw new VciBaseException("{0}的值不符合要求,当前是{1}", new String[]{key, value}, vciError);
                }
            }
@@ -2118,16 +2131,20 @@
                if(editFlag) {
                    //编辑的时候可以都设置
                    try {
                        cbo.setAttributeValueWithNoCheck(key, value, !editFlag);
                    } catch (VCIError vciError) {
//                        if(!SystemAttribute.bosysAttList().contains(key)){
                            cbo.setAttributeValueWithNoCheck(key, value, !editFlag);
//                        }
                    } catch (PLException vciError) {
                        throw new VciBaseException("{0}的值不符合要求,当前是{1}", new String[]{key, value}, vciError);
                    }
                }else{
                    //只需要处理id,name,description,密级即可,其余的都已经被设置了
                    if(basicFields.contains(key) &&StringUtils.isNotBlank(value)){
                        try {
                            cbo.setAttributeValueWithNoCheck(key, value, true);
                        } catch (VCIError vciError) {
//                            if(!SystemAttribute.bosysAttList().contains(key)){
                                cbo.setAttributeValueWithNoCheck(key, value, true);
//                            }
                        } catch (PLException vciError) {
                            throw new VciBaseException("{0}的值不符合要求,当前是{1}", new String[]{key, value}, vciError);
                        }
                    }
@@ -2211,17 +2228,13 @@
        try {
//            platformClientUtil.getBOFactoryService().updateLinkObject(loHolder);
            ServiceProvider.getBOFService().updateLinkObject(clo.getLinkObject());
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        //保存to端或者from端
        BusinessObjectHolder boHolder = new BusinessObjectHolder();
//        toCbo.dealBusinessObjectNullValue();
//        boHolder.value = toCbo.getBusinessObject();
        try{
//            platformClientUtil.getBOFactoryService().updateBusinessObject(boHolder);
            ServiceProvider.getBOFService().updateBusinessObject(toCbo.getBusinessObject());
        } catch (VCIError vciError) {
            platformClientUtil.getBOFactoryService().updateBusinessObject(toCbo.getBusinessObject());
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(!CollectionUtils.isEmpty(formLinkDataDTO.getReleaseFileOids())){
@@ -2315,14 +2328,14 @@
        });
        try {
            platformClientUtil.getBOFactoryService().batchDeleteLinkObject(los.toArray(new LinkObject[0]));
        } catch (VCIError vciError) {
        } catch (PLException vciError) {
            throw WebUtil.getVciBaseException(vciError);
        }
        if(deleteLinkDataDTO.isDeleteFromData()){
            fromBtmDataGroups.forEach((btm,cbos)->{
                try{
                    platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.stream().map(com.vci.client.bof.ClientBusinessObject::getBusinessObject).toArray(BusinessObject[] :: new),1);
                }catch (VCIError vciError) {
                }catch (PLException vciError) {
                    throw WebUtil.getVciBaseException(vciError);
                }
            });
@@ -2331,7 +2344,7 @@
            toBtmDataGroups.forEach((btm,cbos)->{
                try{
                    platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.stream().map(com.vci.client.bof.ClientBusinessObject::getBusinessObject).toArray(BusinessObject[] :: new),1);
                }catch (VCIError vciError) {
                }catch (PLException vciError) {
                    throw WebUtil.getVciBaseException(vciError);
                }
            });