| | |
| | | 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.PLException; |
| | | import com.vci.corba.framework.data.UserInfo; |
| | | import com.vci.corba.omd.data.*; |
| | | import com.vci.corba.omd.lcm.LifeCycle; |
| | | import com.vci.file.pagemodel.VciFileObjectVO; |
| | | import com.vci.dto.*; |
| | | import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus; |
| | | import com.vci.frameworkcore.lcstatuspck.ReleaseDataLCStatus; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.pagemodel.*; |
| | | import com.vci.starter.revision.bo.TreeWrapperOptions; |
| | | import com.vci.starter.web.annotation.bus.VciChangeDataAfter; |
| | | import com.vci.starter.web.annotation.bus.VciChangeDataBefore; |
| | |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.*; |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.dto.*; |
| | | import com.vci.web.enumpck.DeleteTypeEnum; |
| | | import com.vci.web.enumpck.UIFieldTypeEnum; |
| | | import com.vci.web.enumpck.UITreeLoadTypeEnum; |
| | | import com.vci.web.pageModel.*; |
| | | import com.vci.web.query.UIDataGridQuery; |
| | | import com.vci.web.query.UIFormQuery; |
| | | import com.vci.web.query.UILinkTypeDataQuery; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | |
| | | /** |
| | | * UI上的数据查询 |
| | |
| | | UIFormDataVO formDataVO = new UIFormDataVO(); |
| | | replaceMap.put("oid", formQuery.getOid().trim()); |
| | | if(!formDefineVO.isLinkTypeFlag()) { |
| | | List<com.vci.client.bof.ClientBusinessObject> cbos = null; |
| | | List<BusinessObject> cbos = null; |
| | | if (StringUtils.isNotBlank(queryTemplate)) { |
| | | replaceMap.put("oid", formQuery.getOid().trim()); |
| | | cbos = boService.queryCBOByScheme(queryTemplate, conditionMap, replaceMap, null, queryFieldList.stream().collect(Collectors.toList())); |
| | |
| | | cbos = boService.queryCBO(formQuery.getBtmname(), conditionMap, null, queryFieldList.stream().collect(Collectors.toList())); |
| | | } |
| | | if (!CollectionUtils.isEmpty(cbos)) { |
| | | com.vci.client.bof.ClientBusinessObject cbo = cbos.get(0); |
| | | BusinessObject cbo = cbos.get(0); |
| | | formDataVO.setData(boService.cbo2Map(cbo)); |
| | | } else { |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | |
| | | |
| | | if(treeQuery.isQueryRoot()){ |
| | | //是查询根节点 |
| | | List<com.vci.client.bof.ClientBusinessObject> rootCbos = null; |
| | | List<BusinessObject> rootCbos = null; |
| | | if(StringUtils.isNotBlank(queryTemplate)){ |
| | | //说明是菜单里定义了查询模板的 |
| | | rootCbos = boService.queryCBOByScheme(queryTemplate, null, replaceMap); |
| | |
| | | return rootTreeList; |
| | | }else{ |
| | | //这个不是跟节点,但是一般只是增加一个逐级查询,因为全部查询的时候,在根节点已经全部查询完了 |
| | | List<com.vci.client.bof.ClientBusinessObject> thisChildren = null; |
| | | List<BusinessObject> thisChildren = null; |
| | | if (StringUtils.isNotBlank(queryTemplate)) { |
| | | thisChildren = boService.queryCBOByScheme(queryTemplate, treeQuery.getConditionMap(), replaceMap, null, queryFieldList); |
| | | } else { |
| | |
| | | */ |
| | | private void queryTreeForBO(List<Tree> rootTreeList, String queryTemplate,List<String> queryFieldList,TreeQueryObject treeQueryObject) { |
| | | for (Tree rootTree : rootTreeList) { |
| | | List<com.vci.client.bof.ClientBusinessObject> thisChildren = null; |
| | | List<BusinessObject> thisChildren = null; |
| | | Map<String,String> sourceDataMap = rootTree.getAttributes(); |
| | | sourceDataMap.put("f_oid",rootTree.getOid()); |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | |
| | | * @param parentOid 上级的主键 |
| | | * @return 树 |
| | | */ |
| | | private List<Tree> cbo2Trees(Collection<com.vci.client.bof.ClientBusinessObject> cbos,String valueField,String textField,String parentFieldName,boolean showCheckBox,String parentOid){ |
| | | private List<Tree> cbo2Trees(Collection<BusinessObject> cbos,String valueField,String textField,String parentFieldName,boolean showCheckBox,String parentOid){ |
| | | final int[] i = {0}; |
| | | List<Tree> rootList = new ArrayList<>(); |
| | | List<Tree> children = new ArrayList<>(); |
| | |
| | | tree.setOid(getValueByExpress(cbo,valueField)); |
| | | tree.setText(getValueByExpress(cbo,textField)); |
| | | if(StringUtils.isNotBlank(parentFieldName)){ |
| | | tree.setParentId(cbo.getAttributeValue(parentFieldName)); |
| | | tree.setParentId(ObjectTool.getBOAttributeValue(cbo,parentFieldName)); |
| | | } |
| | | tree.setAttributes(boService.cbo2Map(cbo)); |
| | | tree.setIndex(i[0] + ""); |
| | |
| | | List<Tree> children = new ArrayList<>(); |
| | | boAndLOS.stream().forEach(boAndLO->{ |
| | | Tree tree = new Tree(); |
| | | com.vci.client.bof.ClientBusinessObject cbo = new com.vci.client.bof.ClientBusinessObject(); |
| | | cbo.setBusinessObject(boAndLO.bo); |
| | | com.vci.client.bof.ClientLinkObject clo = new com.vci.client.bof.ClientLinkObject(); |
| | | clo.setLinkObject(boAndLO.lo); |
| | | BusinessObject cbo = new BusinessObject(); |
| | | cbo = boAndLO.bo; |
| | | LinkObject clo = new LinkObject(); |
| | | clo = boAndLO.lo; |
| | | Map<String,String> cloMap = loService.clo2Map(clo); |
| | | Map<String,String> cbo2Map = boService.cbo2Map(cbo); |
| | | if(!CollectionUtils.isEmpty(cbo2Map)){ |
| | |
| | | tree.setParentId(boAndLO.lo.oid + TREE_NODE_ID_SEP + boAndLO.lo.fromOid); |
| | | }else { |
| | | if (parentFieldName.contains(".")) { |
| | | tree.setParentId(cbo.getAttributeValue(parentFieldName)); |
| | | tree.setParentId(ObjectTool.getBOAttributeValue(cbo,parentFieldName)); |
| | | } else { |
| | | tree.setParentId(clo.getAttributeValue(parentFieldName)); |
| | | tree.setParentId(ObjectTool.getLOAttributeValue(clo,parentFieldName)); |
| | | } |
| | | } |
| | | |
| | |
| | | * @param fieldExpress 表达式的值 |
| | | * @return 转换后的值 |
| | | */ |
| | | private String getValueByExpress(com.vci.client.bof.ClientBusinessObject cbo,String fieldExpress){ |
| | | private String getValueByExpress(BusinessObject cbo,String fieldExpress){ |
| | | if(StringUtils.isBlank(fieldExpress)){ |
| | | return ""; |
| | | } |
| | |
| | | List<String> fieldList = VciBaseUtil.str2List(fieldExpress); |
| | | StringBuilder sb = new StringBuilder(); |
| | | fieldList.stream().forEach(field->{ |
| | | sb.append(cbo.getAttributeValue(field)).append(" "); |
| | | sb.append(ObjectTool.getBOAttributeValue(cbo,field)).append(" "); |
| | | }); |
| | | return sb.toString().trim(); |
| | | } |
| | |
| | | * @throws VciBaseException 配置或者是调用不成功的时候,会抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult callPreEvent(BaseModelDTOList baseModelDTOList,BaseLinkModelDTOList baseLinkModelDTOList, String preEvent, VciChangeDocumentTypeEnum businessType) throws VciBaseException{ |
| | | public BaseResult callPreEvent(BaseModelDTOList baseModelDTOList, BaseLinkModelDTOList baseLinkModelDTOList, String preEvent, VciChangeDocumentTypeEnum businessType) throws VciBaseException{ |
| | | if((baseModelDTOList == null || CollectionUtils.isEmpty(baseModelDTOList.getDataList())) && (baseLinkModelDTOList == null || CollectionUtils.isEmpty(baseLinkModelDTOList.getDataList()))){ |
| | | return BaseResult.success(); |
| | | } |
| | |
| | | * @throws VciBaseException 执行出错的会抛出异常,或者事件直接返回了异常 |
| | | */ |
| | | @Override |
| | | public BaseResult callPostEvent(Collection<com.vci.client.bof.ClientBusinessObject> cbos, Collection<com.vci.client.bof.ClientLinkObject> clos, String postEvent, VciChangeDocumentTypeEnum businessType) throws VciBaseException{ |
| | | public BaseResult callPostEvent(Collection<BusinessObject> cbos, Collection<LinkObject> clos, String postEvent, VciChangeDocumentTypeEnum businessType) throws VciBaseException{ |
| | | if(CollectionUtils.isEmpty(cbos)){ |
| | | return BaseResult.success(); |
| | | } |
| | | String btmType = !CollectionUtils.isEmpty(cbos)?cbos.stream().findFirst().get().getBtmName():null; |
| | | String linkType = !CollectionUtils.isEmpty(clos)?clos.stream().findFirst().get().getLinkObject().ltName:null; |
| | | String btmType = !CollectionUtils.isEmpty(cbos)?cbos.stream().findFirst().get().btName:null; |
| | | String linkType = !CollectionUtils.isEmpty(clos)?clos.stream().findFirst().get().ltName:null; |
| | | if(StringUtils.isNotBlank(postEvent)){ |
| | | //前置事件 |
| | | //bean的名字#方法; 或者全路径。最后一个是方法的名字 |
| | |
| | | return beforeResult; |
| | | } |
| | | //封装数据 |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> resultCbo = wrapperCbo(formDataDTO,formDefineVO,false,false,false); |
| | | BaseResult<BusinessObject> resultCbo = wrapperCbo(formDataDTO,formDefineVO,false,false,false); |
| | | if(!resultCbo.isSuccess()){ |
| | | return BaseResult.fail(resultCbo.getMsg(),resultCbo.getMsgObjs()); |
| | | } |
| | | //执行保存 |
| | | BaseResult<Map<String,Object>> result = BaseResult.success(); |
| | | com.vci.client.bof.ClientBusinessObject afterCBO = null; |
| | | BusinessObject afterCBO = null; |
| | | try { |
| | | // BusinessObject resultBO = platformClientUtil.getBOFactoryService().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); |
| | | BusinessObject resultBO = platformClientUtil.getBOFService().createBusinessObject(resultCbo.getObj(),false,false); |
| | | afterCBO = new BusinessObject(); |
| | | afterCBO = resultBO; |
| | | result.setObj(boService.cbo2Map(afterCBO)); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){ |
| | | fileObjectService.releasedFile(afterCBO.getBtmName(),afterCBO.getOid(),formDataDTO.getReleaseFileOids()); |
| | | fileObjectService.releasedFile(afterCBO.btName,afterCBO.oid,formDataDTO.getReleaseFileOids()); |
| | | } |
| | | //后置事件 |
| | | String afterEvent = formDataDTO.getPostEvent(); |
| | | try { |
| | | callPostEvent(Arrays.stream(new com.vci.client.bof.ClientBusinessObject[]{afterCBO}).collect(Collectors.toList()),null, afterEvent, VciChangeDocumentTypeEnum.ADD); |
| | | callPostEvent(Arrays.stream(new BusinessObject[]{afterCBO}).collect(Collectors.toList()),null, afterEvent, VciChangeDocumentTypeEnum.ADD); |
| | | }catch (Throwable e){ |
| | | //说明后置事件出现了错误,那么就需要删除以前的这条数据 |
| | | try { |
| | | // platformClientUtil.getBOFactoryService().deleteBusinessObject(afterCBO.getBusinessObject(),1); |
| | | ServiceProvider.getBOFService().deleteBusinessObject(afterCBO.getBusinessObject(),1); |
| | | platformClientUtil.getBOFService().deleteBusinessObject(afterCBO,1); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | * @param newVersion 新版次 |
| | | * @return 执行的结果 |
| | | */ |
| | | private BaseResult<com.vci.client.bof.ClientBusinessObject> wrapperCbo(FormDataDTO formDataDTO,UIFormDefineVO formDefineVO,boolean editFlag,boolean newRevision,boolean newVersion){ |
| | | private BaseResult<BusinessObject> wrapperCbo(FormDataDTO formDataDTO,UIFormDefineVO formDefineVO,boolean editFlag,boolean newRevision,boolean newVersion){ |
| | | //扩展属性的值 |
| | | Map<String, String> data = formDataDTO.getData(); |
| | | Map<String,String> dataLow = new HashMap<>(); |
| | |
| | | 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()){ |
| | |
| | | if(!result.isSuccess()){ |
| | | return result; |
| | | } |
| | | com.vci.client.bof.ClientBusinessObject cbo = createOrGetCbo(dataLow,baseDataMap,editFlag,newRevision,newVersion); |
| | | BusinessObject cbo = createOrGetCbo(dataLow,baseDataMap,editFlag,newRevision,newVersion); |
| | | return BaseResult.success(cbo); |
| | | } |
| | | |
| | |
| | | * @return 基础对象 |
| | | */ |
| | | @Override |
| | | public BaseModel cbo2BaseModel(com.vci.client.bof.ClientBusinessObject cbo){ |
| | | public BaseModel cbo2BaseModel(BusinessObject cbo){ |
| | | BaseModel baseModel = new BaseModel(); |
| | | baseModel.setOid(cbo.getOid()); |
| | | baseModel.setNameOid(cbo.getNameoid()); |
| | | baseModel.setRevisionOid(cbo.getRevisionid()); |
| | | baseModel.setBtmname(cbo.getBtmName()); |
| | | baseModel.setLastR(String.valueOf(cbo.getIsLastR())); |
| | | baseModel.setLastV(String.valueOf(cbo.getIsLastV())); |
| | | baseModel.setFirstR(String.valueOf(cbo.getIsFirstR())); |
| | | baseModel.setFirstV(String.valueOf(cbo.getIsFirstV())); |
| | | baseModel.setCreator(cbo.getCreator()); |
| | | baseModel.setOid(cbo.oid); |
| | | baseModel.setNameOid(cbo.nameoid); |
| | | baseModel.setRevisionOid(cbo.revisionid); |
| | | baseModel.setBtmname(cbo.btName); |
| | | baseModel.setLastR(String.valueOf(cbo.isLastR)); |
| | | baseModel.setLastV(String.valueOf(cbo.isLastV)); |
| | | baseModel.setFirstR(String.valueOf(cbo.isFirstR)); |
| | | baseModel.setFirstV(String.valueOf(cbo.isFirstV)); |
| | | baseModel.setCreator(cbo.creator); |
| | | try { |
| | | baseModel.setCreateTime(new Date(cbo.getCreateTime())); |
| | | baseModel.setLastModifyTime(new Date(cbo.getLastModifyTime())); |
| | | baseModel.setTs(new Date(cbo.getTs())); |
| | | baseModel.setCreateTime(new Date(cbo.createTime)); |
| | | baseModel.setLastModifyTime(new Date(cbo.modifyTime)); |
| | | baseModel.setTs(new Date(cbo.ts)); |
| | | // baseModel.setCheckInTime(VciDateUtil.str2Date(cbo.getCheckinTime(), VciDateUtil.DateTimeFormat)); |
| | | // baseModel.setCheckOutTime(VciDateUtil.str2Date(cbo.getCheckoutTime(), VciDateUtil.DateTimeFormat)); |
| | | }catch (Throwable e){ |
| | | |
| | | } |
| | | baseModel.setLastModifier(cbo.getLastModifier()); |
| | | baseModel.setRevisionRule(cbo.getRevisionRule()); |
| | | baseModel.setVersionRule(cbo.getVersionRule()); |
| | | baseModel.setRevisionSeq(cbo.getRevisionSeq()); |
| | | baseModel.setRevisionValue(cbo.getRevisionValue()); |
| | | baseModel.setVersionSeq(cbo.getVersionSeq()); |
| | | baseModel.setVersionValue(cbo.getVersionValue()); |
| | | baseModel.setLcStatus(cbo.getLcStatus()); |
| | | baseModel.setId(cbo.getId()); |
| | | baseModel.setName(cbo.getName()); |
| | | baseModel.setDescription(cbo.getDescription()); |
| | | baseModel.setOwner(cbo.getOwner()); |
| | | baseModel.setLastModifier(cbo.modifier); |
| | | baseModel.setRevisionRule(cbo.revisionRule); |
| | | baseModel.setVersionRule(cbo.versionRule); |
| | | baseModel.setRevisionSeq(cbo.revisionSeq); |
| | | baseModel.setRevisionValue(cbo.revisionValue); |
| | | baseModel.setVersionSeq(cbo.versionSeq); |
| | | baseModel.setVersionValue(cbo.versionValue); |
| | | baseModel.setLcStatus(cbo.lcStatus); |
| | | baseModel.setId(cbo.id); |
| | | baseModel.setName(cbo.name); |
| | | baseModel.setDescription(cbo.description); |
| | | baseModel.setOwner(cbo.owner); |
| | | // baseModel.setCheckInBy(cbo.getCheckinBy()); |
| | | // baseModel.setCheckOutBy(cbo.getCheckoutBy()); |
| | | baseModel.setCopyFromVersion(cbo.getCopyFromVersion()); |
| | | baseModel.setCopyFromVersion(cbo.fromVersion); |
| | | return baseModel; |
| | | } |
| | | |
| | |
| | | * @return 版本的对象 |
| | | */ |
| | | @Override |
| | | public RevisionValueObject getNextRevision(OsBtmTypeVO btmTypeVO, BaseModel baseModel){ |
| | | public RevisionDataInfo getNextRevision(OsBtmTypeVO btmTypeVO, BaseModel baseModel){ |
| | | try { |
| | | if(baseModel.getRevisionValue() == null){ |
| | | baseModel.setRevisionValue(""); |
| | | } |
| | | return changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextRevisionValueObject(WebUtil.getTableName(btmTypeVO.getId()),baseModel.getNameOid(),btmTypeVO.getRevisionRuleId(),btmTypeVO.isInputRevisionFlag(),baseModel.getRevisionValue())); |
| | | return changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextRevisionValueObject(btmTypeVO.getId(),baseModel.getNameOid(),btmTypeVO.getRevisionRuleId(),btmTypeVO.isInputRevisionFlag(),baseModel.getRevisionValue())); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | * @param info corba对象 |
| | | * @return java对象 |
| | | */ |
| | | private RevisionValueObject changeRevisionValueInfoToObject(RevisionDataInfo info) { |
| | | RevisionValueObject object = new RevisionValueObject(); |
| | | object.setRevisionVal(info.revisionVal); |
| | | object.setRevisionSeq(info.revisionSeq); |
| | | private RevisionDataInfo changeRevisionValueInfoToObject(RevisionDataInfo info) { |
| | | RevisionDataInfo object = new RevisionDataInfo(); |
| | | object.revisionVal = info.revisionVal; |
| | | object.revisionSeq = info.revisionSeq; |
| | | return object; |
| | | } |
| | | |
| | |
| | | * @return 版本的值对象 |
| | | */ |
| | | @Override |
| | | public VersionValueObject getNextVersion(OsBtmTypeVO btmTypeVO, BaseModel baseModel){ |
| | | public VersionDataInfo getNextVersion(OsBtmTypeVO btmTypeVO, BaseModel baseModel){ |
| | | try{ |
| | | return changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextVersionValue(WebUtil.getTableName(btmTypeVO.getId()),baseModel.getRevisionOid(),baseModel.getNameOid(),WebUtil.getInt(btmTypeVO.getVersionRule()))); |
| | | }catch (PLException vciError){ |
| | |
| | | * @param info 版次的值 |
| | | * @return java对象 |
| | | */ |
| | | private VersionValueObject changeRevisionValueInfoToObject(VersionDataInfo info) { |
| | | VersionValueObject object = new VersionValueObject(); |
| | | object.setVersionVal(info.versionVal); |
| | | object.setVersionSeq(info.versionSeq); |
| | | private VersionDataInfo changeRevisionValueInfoToObject(VersionDataInfo info) { |
| | | VersionDataInfo object = new VersionDataInfo(); |
| | | object.versionVal = info.versionVal; |
| | | object.versionSeq = info.versionSeq; |
| | | return object; |
| | | } |
| | | /** |
| | |
| | | //封装数据 |
| | | List<BusinessObject> addBos = new ArrayList<>(); |
| | | List<BusinessObject> afterBOs = new ArrayList<>(); |
| | | List<com.vci.client.bof.ClientBusinessObject> afterCBOs = new ArrayList<>(); |
| | | List<BusinessObject> afterCBOs = new ArrayList<>(); |
| | | Map<String,List<String>> releasedFileOids = new HashMap<>(); |
| | | for(FormDataDTO formDataDTO:formDataDTOList.getFormDataDTOS()) { |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> resultCbo = wrapperCbo(formDataDTO, formDefineVO, false, false, false); |
| | | BaseResult<BusinessObject> resultCbo = wrapperCbo(formDataDTO, formDefineVO, false, false, false); |
| | | if (!resultCbo.isSuccess()) { |
| | | return BaseResult.fail(resultCbo.getMsg(), resultCbo.getMsgObjs()); |
| | | } |
| | | addBos.add(resultCbo.getObj().getBusinessObject()); |
| | | addBos.add(resultCbo.getObj()); |
| | | //执行保存 |
| | | if (!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())) { |
| | | releasedFileOids.put(resultCbo.getObj().getOid(),formDataDTO.getReleaseFileOids()); |
| | | releasedFileOids.put(resultCbo.getObj().oid,formDataDTO.getReleaseFileOids()); |
| | | } |
| | | } |
| | | try { |
| | | // BusinessObject[] resultBOs = platformClientUtil.getBOFactoryService().batchCreateBusinessObject(addBos.toArray(new BusinessObject[0]), false, false); |
| | | BusinessObject[] resultBOs = ServiceProvider.getBOFService().batchCreateBusinessObject(addBos.toArray(new BusinessObject[0]), false, false); |
| | | BusinessObject[] resultBOs = platformClientUtil.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); |
| | | BusinessObject cbo = new BusinessObject(); |
| | | cbo = bo; |
| | | afterCBOs.add(cbo); |
| | | }); |
| | | } catch (PLException vciError) { |
| | |
| | | }catch (Throwable e){ |
| | | //说明后置事件出现了错误,那么就需要删除以前的这条数据 |
| | | try { |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(afterBOs.toArray(new BusinessObject[0]),1); |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(afterBOs.toArray(new BusinessObject[0]),DeleteTypeEnum.OID_AND_TS.getValue()); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | return beforeResult; |
| | | } |
| | | //封装数据 |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> resultCbo = wrapperCbo(formDataDTO,formDefineVO,true,false,false); |
| | | BaseResult<BusinessObject> resultCbo = wrapperCbo(formDataDTO,formDefineVO,true,false,false); |
| | | if(!resultCbo.isSuccess()){ |
| | | return BaseResult.fail(resultCbo.getMsg(),resultCbo.getMsgObjs()); |
| | | } |
| | | //执行保存 |
| | | BaseResult<Map<String,Object>> result = BaseResult.success(); |
| | | try { |
| | | // platformClientUtil.getBOFactoryService().updateBusinessObject(new BusinessObjectHolder(resultCbo.getObj().getBusinessObject())); |
| | | ServiceProvider.getBOFService().updateBusinessObject(resultCbo.getObj().getBusinessObject()); |
| | | platformClientUtil.getBOFService().updateBusinessObject(resultCbo.getObj()); |
| | | result.setObj(boService.cbo2Map(resultCbo.getObj())); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){ |
| | | fileObjectService.releasedFile(resultCbo.getObj().getBtmName(),resultCbo.getObj().getOid(),formDataDTO.getReleaseFileOids()); |
| | | fileObjectService.releasedFile(resultCbo.getObj().btName,resultCbo.getObj().oid,formDataDTO.getReleaseFileOids()); |
| | | } |
| | | //后置事件 |
| | | String afterEvent = formDataDTO.getPostEvent(); |
| | | try { |
| | | callPostEvent(Arrays.stream(new com.vci.client.bof.ClientBusinessObject[]{resultCbo.getObj()}).collect(Collectors.toList()), null,afterEvent, VciChangeDocumentTypeEnum.EDIT); |
| | | callPostEvent(Arrays.stream(new BusinessObject[]{resultCbo.getObj()}).collect(Collectors.toList()), null,afterEvent, VciChangeDocumentTypeEnum.EDIT); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e); |
| | | } |
| | |
| | | * @throws VciBaseException 保存出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult<Map<String, Object>> upRevision(FormDataDTO formDataDTO) throws VciBaseException { |
| | | public BaseResult<Map<String, Object>> upRevision(FormDataDTO formDataDTO) throws VciBaseException, PLException { |
| | | //首先判断对象是否为空 |
| | | VciBaseUtil.alertNotNull(formDataDTO,"修改的数据对象",formDataDTO.getBtmname(),"业务类型的名称",formDataDTO.getFormDefineId(),"表单定义的编号",formDataDTO.getCopyFromVersion(),"老版本的主键"); |
| | | UIFormDefineVO formDefineVO = uiEngineService.getFormById(formDataDTO.getBtmname(), formDataDTO.getFormDefineId()); |
| | |
| | | //说明前置事件没有执行成功 |
| | | return beforeResult; |
| | | } |
| | | //封装数据 |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> resultCbo = wrapperCbo(formDataDTO,formDefineVO,false,formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion()); |
| | | if(!resultCbo.isSuccess()){ |
| | | return BaseResult.fail(resultCbo.getMsg(),resultCbo.getMsgObjs()); |
| | | List<BusinessObject> businessObjects = null; |
| | | Date ts = formDataDTO.getTs(); |
| | | Map<String,String> conditionMap = WebUtil.getOidQuery(formDataDTO.getCopyFromVersion()); |
| | | conditionMap.put("ts", VciDateUtil.date2Str(ts,VciDateUtil.DateTimeMillFormat)); |
| | | conditionMap.put("oid",formDataDTO.getCopyFromVersion()); |
| | | businessObjects = boService.queryCBO(formDataDTO.getBtmname(), conditionMap); |
| | | if(businessObjects.size() ==0){ |
| | | throw new VciBaseException("数据不是最新的,建议您刷新后重新操作"); |
| | | } |
| | | //扩展属性的值 |
| | | Map<String, String> data = formDataDTO.getData(); |
| | | Map<String,String> dataLow = new HashMap<>(); |
| | | data.forEach((key,value)->{ |
| | | dataLow.put(key.toLowerCase(),value); |
| | | }); |
| | | |
| | | Map<String,String> baseDataMap = formDataDTO2MapLow(formDataDTO); |
| | | Map<String,String> allDataMapLow = new HashMap<>(); |
| | | allDataMapLow.putAll(dataLow); |
| | | allDataMapLow.putAll(baseDataMap); |
| | | //判断唯一项 |
| | | BaseResult baseResult = checkUnique(formDefineVO, null, allDataMapLow, true); |
| | | if(!baseResult.isSuccess()){ |
| | | return baseResult; |
| | | } |
| | | BusinessObject businessObject = platformClientUtil.getBOFService() |
| | | .revisionBusinessObject(businessObjects.get(0), null, !formDataDTO.isUpVersion(),true, false, false); |
| | | //执行保存 |
| | | BaseResult<Map<String,Object>> result = BaseResult.success(); |
| | | try { |
| | | // BusinessObject bo = platformClientUtil.getBOFactoryService().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 (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){ |
| | | fileObjectService.releasedFile(resultCbo.getObj().getBtmName(),resultCbo.getObj().getOid(),formDataDTO.getReleaseFileOids()); |
| | | } |
| | | BaseResult<Map<String, Object>> result = BaseResult.success(); |
| | | result.setObj(boService.cbo2Map(businessObject)); |
| | | //后置事件 |
| | | String afterEvent = formDataDTO.getPostEvent(); |
| | | try { |
| | | callPostEvent(Arrays.stream(new com.vci.client.bof.ClientBusinessObject[]{resultCbo.getObj()}).collect(Collectors.toList()), null,afterEvent, VciChangeDocumentTypeEnum.EDIT); |
| | | callPostEvent(Arrays.stream(new BusinessObject[]{businessObject}).collect(Collectors.toList()), null,afterEvent, VciChangeDocumentTypeEnum.EDIT); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e); |
| | | } |
| | |
| | | //封装数据 |
| | | List<BusinessObject> updateCBOS = new ArrayList<>(); |
| | | Map<String,List<String>> releasedFileOids = new HashMap<>(); |
| | | List<com.vci.client.bof.ClientBusinessObject> afterCBOs = new ArrayList<>(); |
| | | List<BusinessObject> afterCBOs = new ArrayList<>(); |
| | | for(FormDataDTO formDataDTO:formDataDTOList.getFormDataDTOS()) { |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> resultCbo = wrapperCbo(formDataDTO, formDefineVO, true, false, false); |
| | | BaseResult<BusinessObject> resultCbo = wrapperCbo(formDataDTO, formDefineVO, true, false, false); |
| | | if (!resultCbo.isSuccess()) { |
| | | return BaseResult.fail(resultCbo.getMsg(), resultCbo.getMsgObjs()); |
| | | } |
| | | updateCBOS.add(resultCbo.getObj().getBusinessObject()); |
| | | updateCBOS.add(resultCbo.getObj()); |
| | | //执行保存 |
| | | if (!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())) { |
| | | releasedFileOids.put(resultCbo.getObj().getOid(),formDataDTO.getReleaseFileOids()); |
| | | releasedFileOids.put(resultCbo.getObj().oid,formDataDTO.getReleaseFileOids()); |
| | | } |
| | | } |
| | | try { |
| | |
| | | String btmName = deleteDataDTO.getDataList().get(0).getBtmname(); |
| | | List<String> oidList = deleteDataDTO.getDataList().stream().map(BaseModelDTO::getOid).collect(Collectors.toList()); |
| | | //看看级联删除。只有自己引用自己的时候可以级联删除 |
| | | List<com.vci.client.bof.ClientBusinessObject> cbo = null; |
| | | List<BusinessObject> cbo = null; |
| | | if(deleteDataDTO.isCascade()){ |
| | | //级联删除 |
| | | OsBtmTypeVO btmTypeVO = btmService.getBtmById(btmName); |
| | |
| | | if(CollectionUtils.isEmpty(cbo)){ |
| | | return BaseResult.fail("没有在系统中找到这些数据,未执行删除操作"); |
| | | } |
| | | List<com.vci.client.bof.ClientBusinessObject> finalCbo = cbo; |
| | | Collection<Collection<String>> oidCollections = WebUtil.switchCollectionForOracleIn(finalCbo.stream().map(com.vci.client.bof.ClientBusinessObject::getOid).collect(Collectors.toList())); |
| | | List<BusinessObject> finalCbo = cbo; |
| | | Collection<Collection<String>> oidCollections = WebUtil.switchCollectionForOracleIn(finalCbo.stream().map(bo -> bo.oid).collect(Collectors.toList())); |
| | | List<OsUsedAttributeVO> usedAttributeVOS = null; |
| | | boolean adminCascade = false; |
| | | if("admin".equalsIgnoreCase(VciBaseUtil.getCurrentUserId()) && deleteDataDTO.isAdminCascade()){ |
| | |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put(usedAttributeVO.getId(),QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oids.toArray(new String[0])) + ")"); |
| | | if(StringUtils.isNotBlank(usedAttributeVO.getPkBtmType())) { |
| | | List<com.vci.client.bof.ClientBusinessObject> tempCbos = boService.queryCBO(usedAttributeVO.getPkBtmType(), conditionMap); |
| | | List<BusinessObject> tempCbos = boService.queryCBO(usedAttributeVO.getPkBtmType(), conditionMap); |
| | | if(!CollectionUtils.isEmpty(tempCbos)){ |
| | | finalCbo.addAll(tempCbos); |
| | | } |
| | |
| | | } |
| | | VciBaseUtil.switchCollectionForOracleIn(finalCbo).stream().forEach(cbos->{ |
| | | try { |
| | | // 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); |
| | | platformClientUtil.getBOFService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),1); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | }); |
| | | System.out.println("zheshi shazi "); |
| | | return BaseResult.success(); |
| | | } |
| | | |
| | |
| | | //说明前置事件没有执行成功 |
| | | return beforeResult; |
| | | } |
| | | com.vci.client.bof.ClientLinkObject clo = null; |
| | | LinkObject clo = null; |
| | | String prefix = ""; |
| | | if(formLinkDataDTO.isDirection()){ |
| | | prefix = LO_FROM_PREFIX; |
| | |
| | | throw new VciBaseException(formLinkDataDTO.isDirection()?"from端":"to端" + "的业务类型为空"); |
| | | } |
| | | |
| | | //查询from端的 |
| | | com.vci.client.bof.ClientBusinessObject fromCbo = new com.vci.client.bof.ClientBusinessObject(); |
| | | try { |
| | | // fromCbo.setBusinessObject(platformClientUtil.getBOFactoryService().readBusinessObject(fromOid,fromBtmName)); |
| | | fromCbo.setBusinessObject(ServiceProvider.getBOFService().readBusinessObject(fromOid,fromBtmName)); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | String finalPrefix = prefix; |
| | | formLinkDataDTO.getData().forEach((key, value)->{ |
| | | if(key.toLowerCase().startsWith(finalPrefix)){ |
| | |
| | | } |
| | | }); |
| | | //封装to端的 |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> result = wrapperToCbo(formLinkDataDTO,formDefineVO,toOid,toBtmName,boData); |
| | | BaseResult<BusinessObject> result = wrapperToCbo(formLinkDataDTO,formDefineVO,toOid,toBtmName,boData); |
| | | if(!result.isSuccess()){ |
| | | return BaseResult.fail(result.getMsg(),result.getMsgObjs()); |
| | | } |
| | | com.vci.client.bof.ClientBusinessObject toCbo = result.getObj(); |
| | | BusinessObject toCbo = result.getObj(); |
| | | //初始化链接类型的值 |
| | | BaseResult<com.vci.client.bof.ClientLinkObject> resultClo = wrapperOnlyCLO(formLinkDataDTO, loData, formDefineVO, false); |
| | | BaseResult<LinkObject> resultClo = wrapperOnlyCLO(formLinkDataDTO, loData, formDefineVO, false); |
| | | if(!resultClo.isSuccess()){ |
| | | return BaseResult.fail(resultClo.getMsg(),resultClo.getMsgObjs()); |
| | | } |
| | | clo = resultClo.getObj(); |
| | | if(formLinkDataDTO.isDirection()){ |
| | | clo.setFromBO(toCbo); |
| | | clo.setToBO(fromCbo); |
| | | } else { |
| | | clo.setFromBO(fromCbo); |
| | | clo.setToBO(toCbo); |
| | | if(StringUtils.isBlank(clo.toOid)){ |
| | | clo.toOid = toCbo.oid; |
| | | } |
| | | //执行保存 |
| | | BusinessObject[] bos = new BusinessObject[1]; |
| | | toCbo.dealBusinessObjectNullValue(); |
| | | clo.dealLinkObjectNullValue(); |
| | | bos[0] = toCbo.getBusinessObject(); |
| | | ObjectTool.dealBusinessObjectNullValue(toCbo); |
| | | bos[0] = toCbo; |
| | | try { |
| | | // platformClientUtil.getBOFactoryService().createBusinessObjectWithLink(bosHolder,loHolder); |
| | | ServiceProvider.getBOFService().createBusinessObjectWithLink(bos,clo.getLinkObject()); |
| | | platformClientUtil.getBOFService().createBusinessObjectWithLink(bos,clo); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | if(!CollectionUtils.isEmpty(formLinkDataDTO.getReleaseFileOids())){ |
| | | fileObjectService.releasedFile(formLinkDataDTO.getLinkType(),clo.getOid(),formLinkDataDTO.getReleaseFileOids()); |
| | | fileObjectService.releasedFile(formLinkDataDTO.getLinkType(),clo.oid,formLinkDataDTO.getReleaseFileOids()); |
| | | } |
| | | //后置事件 |
| | | String afterEvent = formLinkDataDTO.getPostEvent(); |
| | | try { |
| | | callPostEvent(null,Arrays.stream(new com.vci.client.bof.ClientLinkObject[]{clo}).collect(Collectors.toList()), afterEvent, VciChangeDocumentTypeEnum.ADD); |
| | | callPostEvent(null,Arrays.stream(new LinkObject[]{clo}).collect(Collectors.toList()), afterEvent, VciChangeDocumentTypeEnum.ADD); |
| | | }catch (Throwable e){ |
| | | //说明后置事件出现了错误,那么就需要删除以前的这条数据 |
| | | try { |
| | | // platformClientUtil.getBOFactoryService().deleteBusinessObject(toCbo.getBusinessObject(),1); |
| | | // platformClientUtil.getBOFactoryService().deleteLinkObject(clo.getLinkObject()); |
| | | ServiceProvider.getBOFService().deleteBusinessObject(toCbo.getBusinessObject(),1); |
| | | ServiceProvider.getBOFService().deleteLinkObject(clo.getLinkObject()); |
| | | platformClientUtil.getBOFService().deleteBusinessObject(toCbo,1); |
| | | platformClientUtil.getBOFService().deleteLinkObject(clo); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e); |
| | | } |
| | | return BaseResult.success(clo.getOid()); |
| | | return BaseResult.success(clo.oid); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param editFlag 是否为编辑 |
| | | * @return 链接类型的内容 |
| | | */ |
| | | private BaseResult<com.vci.client.bof.ClientLinkObject> wrapperOnlyCLO(FormLinkDataDTO formLinkDataDTO,Map<String,String> loData,UIFormDefineVO formDefineVO,boolean editFlag){ |
| | | private BaseResult<LinkObject> wrapperOnlyCLO(FormLinkDataDTO formLinkDataDTO,Map<String,String> loData,UIFormDefineVO formDefineVO,boolean editFlag){ |
| | | Map<String,String> baseDataMap = formLinkDataDTO2MapLow(formLinkDataDTO); |
| | | Map<String,String> allDataMap = new HashMap<>(); |
| | | allDataMap.putAll(loData); |
| | |
| | | return result; |
| | | } |
| | | //处理业务类型得到数据 |
| | | ClientLinkObject clo ; |
| | | LinkObject clo ; |
| | | if(editFlag){ |
| | | try { |
| | | // LinkObject linkObject = platformClientUtil.getBOFactoryService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType()); |
| | | LinkObject linkObject = ServiceProvider.getBOFService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType()); |
| | | clo = new ClientLinkObject(); |
| | | clo.setLinkObject(linkObject); |
| | | LinkObject linkObject = platformClientUtil.getBOFService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType()); |
| | | clo = linkObject; |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | }else{ |
| | | clo = new ClientLinkObject(); |
| | | clo = new LinkObject(); |
| | | //处理初始化的数据 |
| | | clo.setOid(VciBaseUtil.getPk()); |
| | | clo.setCreator(VciBaseUtil.getCurrentUserId()); |
| | | clo.setCreateTime(System.currentTimeMillis()); |
| | | clo.setTs(System.currentTimeMillis()); |
| | | clo.setLoName(formLinkDataDTO.getLinkType()); |
| | | clo.oid = VciBaseUtil.getPk(); |
| | | clo.creator = VciBaseUtil.getCurrentUserId(); |
| | | clo.createTime = System.currentTimeMillis(); |
| | | clo.ts = System.currentTimeMillis(); |
| | | clo.ltName = formLinkDataDTO.getLinkType(); |
| | | clo.toOid = formLinkDataDTO.getToid(); |
| | | clo.toNameOid = formLinkDataDTO.getTnameoid(); |
| | | clo.toRevOid = formLinkDataDTO.getTrevisionoid(); |
| | | clo.toBTName = formLinkDataDTO.getTbtmname(); |
| | | clo.fromOid = formLinkDataDTO.getFoid(); |
| | | clo.fromBTName = formLinkDataDTO.getFbtmname(); |
| | | clo.fromNameOid = formLinkDataDTO.getFnameoid(); |
| | | clo.fromRevOid = formLinkDataDTO.getFrevisionoid(); |
| | | } |
| | | // |
| | | allDataMap.forEach((key,value)->{ |
| | | LinkObject finalClo = clo; |
| | | allDataMap.forEach((key, value)->{ |
| | | if(editFlag&&("lastmodifier".equalsIgnoreCase(key) || "lastmodifytime".equalsIgnoreCase(key) |
| | | || "ts".equalsIgnoreCase(key) || "creator".equalsIgnoreCase(key) |
| | | || "createtime".equalsIgnoreCase(key))){ |
| | | //平台不能传递这个 |
| | | }else{ |
| | | loService.setAttribute(clo,key,value); |
| | | loService.setAttribute(finalClo,key,value); |
| | | } |
| | | }); |
| | | return BaseResult.success(clo); |
| | |
| | | * @param boData to的数据 |
| | | * @return 包含的对象 |
| | | */ |
| | | private BaseResult<com.vci.client.bof.ClientBusinessObject> wrapperToCbo(FormLinkDataDTO formLinkDataDTO,UIFormDefineVO formDefineVO,String toOid,String toBtmName,Map<String,String> boData){ |
| | | private BaseResult<BusinessObject> wrapperToCbo(FormLinkDataDTO formLinkDataDTO,UIFormDefineVO formDefineVO,String toOid,String toBtmName,Map<String,String> boData){ |
| | | Map<String,String> dataLow = new HashMap<>(); |
| | | boData.forEach((key,value)->{ |
| | | dataLow.put(key.toLowerCase(),value); |
| | |
| | | if(!result.isSuccess()){ |
| | | return result; |
| | | } |
| | | com.vci.client.bof.ClientBusinessObject cbo = createOrGetCbo(dataLow,baseDataMap,editFlag,formLinkDataDTO.isToUpRevision(),formLinkDataDTO.isToUpVersion()); |
| | | BusinessObject cbo = createOrGetCbo(dataLow,baseDataMap,editFlag,formLinkDataDTO.isToUpRevision(),formLinkDataDTO.isToUpVersion()); |
| | | return BaseResult.success(cbo); |
| | | |
| | | } |
| | |
| | | * @param newVersion 是否升版次 |
| | | * @return cbo对象 |
| | | */ |
| | | public com.vci.client.bof.ClientBusinessObject createOrGetCbo(Map<String,String> dataLowMap,Map<String,String> baseDataMap,boolean editFlag,boolean newRevision,boolean newVersion){ |
| | | public BusinessObject createOrGetCbo(Map<String,String> dataLowMap,Map<String,String> baseDataMap,boolean editFlag,boolean newRevision,boolean newVersion){ |
| | | String btmName = baseDataMap.get("btmname"); |
| | | String oid = baseDataMap.get("oid"); |
| | | // ClientBusinessObject cbo = new ClientBusinessObject(); |
| | | com.vci.client.bof.ClientBusinessObject cbo = new com.vci.client.bof.ClientBusinessObject(); |
| | | // BusinessObject cbo = new BusinessObject(); |
| | | BusinessObject cbo = new BusinessObject(); |
| | | 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)); |
| | | cbo = platformClientUtil.getBOFService().readBusinessObject(editFlag?oid:copyfromversion,btmName); |
| | | } catch (PLException vciError) { |
| | | throw new VciBaseException("使用主键在系统中没有查询到数据",new String[]{oid},vciError); |
| | | } |
| | | if(btmTypeVO.isRevisionFlag() && newRevision){ |
| | | cbo.setOid(VciBaseUtil.getPk()); |
| | | cbo.setCopyFromVersion(copyfromversion); |
| | | cbo.oid = VciBaseUtil.getPk(); |
| | | cbo.fromVersion = copyfromversion; |
| | | if(btmTypeVO.isInputRevisionFlag() && StringUtils.isNotBlank(baseDataMap.getOrDefault("revisionvalue",""))){ |
| | | //手动的,所以不处理版本规则了 |
| | | cbo.setRevisionValue(baseDataMap.get("revisionvalue")); |
| | | cbo.revisionValue = baseDataMap.get("revisionvalue"); |
| | | }else{ |
| | | //说明是升版 |
| | | BaseModel baseModel = cbo2BaseModel(cbo); |
| | | RevisionValueObject revisionValueObject = getNextRevision(btmTypeVO,baseModel); |
| | | cbo.setRevisionid(VciBaseUtil.getPk()); |
| | | cbo.setRevisionSeq((short) revisionValueObject.getRevisionSeq()); |
| | | cbo.setRevisionValue(revisionValueObject.getRevisionVal()); |
| | | cbo.setIsLastR(true); |
| | | cbo.setIsFirstR(false); |
| | | RevisionDataInfo revisionValueObject = getNextRevision(btmTypeVO,baseModel); |
| | | cbo.revisionid = VciBaseUtil.getPk(); |
| | | cbo.revisionSeq = revisionValueObject.revisionSeq; |
| | | cbo.revisionValue = revisionValueObject.revisionVal; |
| | | cbo.isLastR = true; |
| | | cbo.isFirstR = false; |
| | | //处理版次 |
| | | cbo.setVersionValue(getFirstVersion(btmTypeVO.getVersionRule())); |
| | | cbo.setVersionRule(btmTypeVO.getVersionRule()); |
| | | cbo.setVersionSeq((short) 0); |
| | | cbo.setIsLastV(true); |
| | | cbo.setIsFirstV(true); |
| | | cbo.versionValue = getFirstVersion(btmTypeVO.getVersionRule()); |
| | | cbo.versionRule = btmTypeVO.getVersionRule(); |
| | | cbo.versionSeq = (short) 0; |
| | | cbo.isLastV = true; |
| | | cbo.isFirstV = true; |
| | | } |
| | | //升版的时候,生命周期的状态需要改动到默认状态 |
| | | if(StringUtils.isNotBlank(btmTypeVO.getLifeCycleId())){ |
| | | //查询生命周期 |
| | | // OsLifeCycleVO lifeCycleVO = lifeCycleService.getLifeCycleById(btmTypeVO.getLifeCycleId()); |
| | | LifeCycle lifeCycleVO = null; |
| | | try { |
| | | lifeCycleVO = ServiceProvider.getOMDService().getLifeCycleService().getLifeCycle(btmTypeVO.getLifeCycleId()); |
| | | lifeCycleVO = platformClientUtil.getLifeCycleService().getLifeCycle(btmTypeVO.getLifeCycleId()); |
| | | } catch (PLException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if(lifeCycleVO == null || StringUtils.isBlank(lifeCycleVO.oid)){ |
| | | throw new VciBaseException("{0}里的生命周期设置得不正确,在系统中没有找到{1}这个生命周期",new String[]{btmTypeVO.getName(),btmTypeVO.getLifeCycleId()}); |
| | | } |
| | | cbo.setLcStatus(lifeCycleVO.startState); |
| | | cbo.lcStatus = lifeCycleVO.startState; |
| | | } |
| | | } |
| | | if(btmTypeVO.isRevisionFlag() && newVersion){ |
| | | cbo.setCopyFromVersion(copyfromversion); |
| | | cbo.setOid(VciBaseUtil.getPk()); |
| | | cbo.fromVersion = copyfromversion; |
| | | cbo.oid = VciBaseUtil.getPk(); |
| | | //这是升版次,不存在即升版本,又升版次的情况 |
| | | BaseModel baseModel = cbo2BaseModel(cbo); |
| | | VersionValueObject versionValueObject = getNextVersion(btmTypeVO,baseModel); |
| | | cbo.setVersionValue(versionValueObject.getVersionVal()); |
| | | cbo.setVersionSeq((short) versionValueObject.getVersionSeq()); |
| | | cbo.setIsLastV(true); |
| | | cbo.setIsFirstV(false); |
| | | VersionDataInfo versionValueObject = getNextVersion(btmTypeVO,baseModel); |
| | | cbo.versionValue = versionValueObject.versionVal; |
| | | cbo.versionSeq = versionValueObject.versionSeq; |
| | | cbo.isLastV = true; |
| | | cbo.isFirstV = false; |
| | | //升版的时候,生命周期的状态需要改动到默认状态 |
| | | if(StringUtils.isNotBlank(btmTypeVO.getLifeCycleId())){ |
| | | //查询生命周期 |
| | | // OsLifeCycleVO lifeCycleVO = lifeCycleService.getLifeCycleById(btmTypeVO.getLifeCycleId()); |
| | | LifeCycle lifeCycleVO = null; |
| | | try { |
| | | lifeCycleVO = ServiceProvider.getOMDService().getLifeCycleService().getLifeCycle(btmTypeVO.getLifeCycleId()); |
| | | lifeCycleVO = platformClientUtil.getLifeCycleService().getLifeCycle(btmTypeVO.getLifeCycleId()); |
| | | } catch (PLException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if(lifeCycleVO == null || StringUtils.isBlank(lifeCycleVO.oid)){ |
| | | throw new VciBaseException("{0}里的生命周期设置得不正确,在系统中没有找到{1}这个生命周期",new String[]{btmTypeVO.getName(),btmTypeVO.getLifeCycleId()}); |
| | | } |
| | | cbo.setLcStatus(lifeCycleVO.startState); |
| | | cbo.lcStatus = lifeCycleVO.startState; |
| | | } |
| | | } |
| | | }else{ |
| | | //我们需要将属性初始化 |
| | | if(StringUtils.isBlank(cbo.getOid()) || (newRevision || newVersion)){ |
| | | cbo.setOid(VciBaseUtil.getPk()); |
| | | if(StringUtils.isBlank(cbo.oid) || (newRevision || newVersion)){ |
| | | cbo.oid = VciBaseUtil.getPk(); |
| | | } |
| | | if(StringUtils.isBlank(cbo.getCreator())){ |
| | | cbo.setCreator(VciBaseUtil.getCurrentUserId()); |
| | | if(StringUtils.isBlank(cbo.creator)){ |
| | | cbo.creator = VciBaseUtil.getCurrentUserId(); |
| | | } |
| | | if(cbo.getCreateTime() != 0){ |
| | | cbo.setCreateTime(System.currentTimeMillis()); |
| | | if(cbo.createTime != 0){ |
| | | cbo.createTime = System.currentTimeMillis(); |
| | | } |
| | | if(StringUtils.isBlank(cbo.getOwner())){ |
| | | cbo.setOwner(cbo.getCreator()); |
| | | if(StringUtils.isBlank(cbo.owner)){ |
| | | cbo.owner = cbo.creator; |
| | | } |
| | | cbo.setTs(System.currentTimeMillis()); |
| | | if(StringUtils.isNotBlank(btmTypeVO.getLifeCycleId()) && (StringUtils.isBlank(cbo.getLcStatus()) || newRevision || newVersion)){ |
| | | cbo.ts = System.currentTimeMillis(); |
| | | if(StringUtils.isNotBlank(btmTypeVO.getLifeCycleId()) && (StringUtils.isBlank(cbo.lcStatus) || newRevision || newVersion)){ |
| | | //查询生命周期 |
| | | OsLifeCycleVO lifeCycleVO = lifeCycleService.getLifeCycleById(btmTypeVO.getLifeCycleId()); |
| | | if(lifeCycleVO == null || StringUtils.isBlank(lifeCycleVO.getOid())){ |
| | | throw new VciBaseException("{0}里的生命周期设置得不正确,在系统中没有找到{1}这个生命周期",new String[]{btmTypeVO.getName(),btmTypeVO.getLifeCycleId()}); |
| | | } |
| | | cbo.setLcStatus(lifeCycleVO.getStartStatus()); |
| | | cbo.setLctId(btmTypeVO.getLifeCycleId()); |
| | | cbo.lcStatus = lifeCycleVO.getStartStatus(); |
| | | cbo.lctId = btmTypeVO.getLifeCycleId(); |
| | | } |
| | | if(StringUtils.isBlank(cbo.getBtmName())){ |
| | | cbo.setBtmName(btmTypeVO.getId()); |
| | | if(StringUtils.isBlank(cbo.btName)){ |
| | | cbo.btName = btmTypeVO.getId(); |
| | | } |
| | | if(btmTypeVO.isRevisionFlag()){ |
| | | //要管理版本 |
| | | if(btmTypeVO.isInputRevisionFlag() && StringUtils.isNotBlank(baseDataMap.getOrDefault("revisionvalue",""))){ |
| | | //手动的,所以不处理版本规则了 |
| | | cbo.setRevisionValue(baseDataMap.get("revisionvalue")); |
| | | cbo.revisionValue = baseDataMap.get("revisionvalue"); |
| | | }else { |
| | | OsRevisionRuleVO ruleVO = revisionRuleServiceI.getRevisionRuleById(btmTypeVO.getRevisionRuleId()); |
| | | if (ruleVO == null || StringUtils.isBlank(ruleVO.getOid())) { |
| | | throw new VciBaseException("{0}里的版本规则设置得不正确,在系统中没有找到{1}这个版本规则", new String[]{btmTypeVO.getName(), btmTypeVO.getRevisionRuleId()}); |
| | | } |
| | | cbo.setRevisionValue(ruleVO.getStartCode()); |
| | | cbo.revisionValue = ruleVO.getInitialValue(); |
| | | } |
| | | if (StringUtils.isBlank(cbo.getNameoid())) { |
| | | cbo.setNameoid(VciBaseUtil.getPk()); |
| | | if (StringUtils.isBlank(cbo.nameoid)) { |
| | | cbo.nameoid = VciBaseUtil.getPk(); |
| | | } |
| | | if (StringUtils.isBlank(cbo.getRevisionid())) { |
| | | cbo.setRevisionid(VciBaseUtil.getPk()); |
| | | if (StringUtils.isBlank(cbo.revisionid)) { |
| | | cbo.revisionid = VciBaseUtil.getPk(); |
| | | } |
| | | cbo.setIsFirstR(true); |
| | | cbo.setIsLastR(true); |
| | | cbo.setRevisionRule(btmTypeVO.getRevisionRuleId()); |
| | | cbo.setRevisionSeq((short) 0); |
| | | cbo.isFirstR = true; |
| | | cbo.isLastR = true; |
| | | cbo.revisionRule = btmTypeVO.getRevisionRuleId(); |
| | | cbo.revisionSeq = (short) 0; |
| | | //看看是否需要处理版次 |
| | | |
| | | cbo.setVersionValue(getFirstVersion(btmTypeVO.getVersionRule())); |
| | | cbo.setVersionRule(btmTypeVO.getVersionRule()); |
| | | cbo.setVersionSeq((short) 0); |
| | | cbo.setIsLastV(true); |
| | | cbo.setIsFirstV(true); |
| | | cbo.versionValue = getFirstVersion(btmTypeVO.getVersionRule()); |
| | | cbo.versionRule = btmTypeVO.getVersionRule(); |
| | | cbo.versionSeq = (short) 0; |
| | | cbo.isLastV = true; |
| | | cbo.isFirstV = true; |
| | | } |
| | | } |
| | | // Iterator<Map.Entry<String, String>> iterator = baseDataMap.entrySet().iterator(); |
| | |
| | | * @param editFlag 是否为编辑 |
| | | */ |
| | | @Override |
| | | public void setValueToCbo(Map<String, String> dataLow, Map<String, String> baseDataLow, com.vci.client.bof.ClientBusinessObject cbo, boolean editFlag){ |
| | | public void setValueToCbo(Map<String, String> dataLow, Map<String, String> baseDataLow, BusinessObject cbo, boolean editFlag){ |
| | | dataLow.forEach((key,value)->{ |
| | | if(editFlag&¬SendOnEdit(key)){ |
| | | //平台不能传递这个 |
| | | }else{ |
| | | try { |
| | | // if(!SystemAttribute.bosysAttList().contains(key)){ |
| | | cbo.setAttributeValueWithNoCheck(key, value, !editFlag); |
| | | // } |
| | | } catch (PLException vciError) { |
| | | throw new VciBaseException("{0}的值不符合要求,当前是{1}", new String[]{key, value}, vciError); |
| | | } |
| | | ObjectTool.setBOAttributeValue(cbo,key,value); |
| | | } |
| | | }); |
| | | baseDataLow.forEach((key,value)->{ |
| | |
| | | }else{ |
| | | if(editFlag) { |
| | | //编辑的时候可以都设置 |
| | | try { |
| | | // if(!SystemAttribute.bosysAttList().contains(key)){ |
| | | cbo.setAttributeValueWithNoCheck(key, value, !editFlag); |
| | | // } |
| | | } catch (PLException vciError) { |
| | | throw new VciBaseException("{0}的值不符合要求,当前是{1}", new String[]{key, value}, vciError); |
| | | } |
| | | ObjectTool.setBOAttributeValue(cbo,key,value); |
| | | }else{ |
| | | //只需要处理id,name,description,密级即可,其余的都已经被设置了 |
| | | if(basicFields.contains(key) &&StringUtils.isNotBlank(value)){ |
| | | try { |
| | | // if(!SystemAttribute.bosysAttList().contains(key)){ |
| | | cbo.setAttributeValueWithNoCheck(key, value, true); |
| | | // } |
| | | } catch (PLException vciError) { |
| | | throw new VciBaseException("{0}的值不符合要求,当前是{1}", new String[]{key, value}, vciError); |
| | | } |
| | | ObjectTool.setBOAttributeValue(cbo,key,value); |
| | | } |
| | | } |
| | | } |
| | |
| | | //说明前置事件没有执行成功 |
| | | return beforeResult; |
| | | } |
| | | com.vci.client.bof.ClientLinkObject clo = null; |
| | | LinkObject clo = null; |
| | | String prefix = formLinkDataDTO.isDirection()?LO_FROM_PREFIX:LO_TO_PREFIX; |
| | | String toOid = formLinkDataDTO.isDirection()?formLinkDataDTO.getFoid():formLinkDataDTO.getToid(); |
| | | String toBtmName = formLinkDataDTO.isDirection()?formLinkDataDTO.getFbtmname():formLinkDataDTO.getTbtmname(); |
| | | String fromOid = formLinkDataDTO.isDirection()?formLinkDataDTO.getToid():formLinkDataDTO.getFoid(); |
| | | String fromBtmName = formLinkDataDTO.isDirection()?formLinkDataDTO.getTbtmname():formLinkDataDTO.getFbtmname(); |
| | | |
| | | Map<String,String> boData = new HashMap<>(); |
| | | Map<String,String> loData = new HashMap<>(); |
| | |
| | | } |
| | | }); |
| | | } |
| | | com.vci.client.bof.ClientBusinessObject toCbo =null; |
| | | BusinessObject toCbo =null; |
| | | if(!CollectionUtils.isEmpty(boData)) { |
| | | //封装to端的 |
| | | BaseResult<com.vci.client.bof.ClientBusinessObject> result = wrapperToCbo(formLinkDataDTO, formDefineVO, toOid, toBtmName, boData); |
| | | BaseResult<BusinessObject> result = wrapperToCbo(formLinkDataDTO, formDefineVO, toOid, toBtmName, boData); |
| | | if (!result.isSuccess()) { |
| | | return BaseResult.fail(result.getMsg(), result.getMsgObjs()); |
| | | } |
| | |
| | | } |
| | | |
| | | //初始化链接类型的值 |
| | | BaseResult<com.vci.client.bof.ClientLinkObject> resultClo = wrapperOnlyCLO(formLinkDataDTO, loData, formDefineVO, true); |
| | | BaseResult<LinkObject> resultClo = wrapperOnlyCLO(formLinkDataDTO, loData, formDefineVO, true); |
| | | if(!resultClo.isSuccess()){ |
| | | return BaseResult.fail(resultClo.getMsg(),resultClo.getMsgObjs()); |
| | | } |
| | | clo = resultClo.getObj(); |
| | | if(toCbo!=null) { |
| | | if (formLinkDataDTO.isDirection()) { |
| | | clo.setFromBO(toCbo); |
| | | } else { |
| | | clo.setToBO(toCbo); |
| | | } |
| | | } |
| | | // LinkObjectHolder loHolder = new LinkObjectHolder(); |
| | | // loHolder.value = clo.getLinkObject(); |
| | | try { |
| | | // platformClientUtil.getBOFactoryService().updateLinkObject(loHolder); |
| | | ServiceProvider.getBOFService().updateLinkObject(clo.getLinkObject()); |
| | | platformClientUtil.getBOFService().updateLinkObject(clo); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | //保存to端或者from端 |
| | | try{ |
| | | platformClientUtil.getBOFactoryService().updateBusinessObject(toCbo.getBusinessObject()); |
| | | platformClientUtil.getBOFactoryService().updateBusinessObject(toCbo); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | if(!CollectionUtils.isEmpty(formLinkDataDTO.getReleaseFileOids())){ |
| | | fileObjectService.releasedFile(formLinkDataDTO.getLinkType(),clo.getOid(),formLinkDataDTO.getReleaseFileOids()); |
| | | fileObjectService.releasedFile(formLinkDataDTO.getLinkType(),clo.oid,formLinkDataDTO.getReleaseFileOids()); |
| | | } |
| | | //后置事件 |
| | | String afterEvent = formLinkDataDTO.getPostEvent(); |
| | | try { |
| | | callPostEvent(null,Arrays.stream(new com.vci.client.bof.ClientLinkObject[]{clo}).collect(Collectors.toList()), afterEvent, VciChangeDocumentTypeEnum.ADD); |
| | | callPostEvent(null,Arrays.stream(new LinkObject[]{clo}).collect(Collectors.toList()), afterEvent, VciChangeDocumentTypeEnum.ADD); |
| | | }catch (Throwable e){ |
| | | //后置事件有问题了就只能是这样了,没办法恢复 |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e); |
| | | } |
| | | return BaseResult.success(clo.getOid()); |
| | | return BaseResult.success(clo.oid); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(deleteLinkDataDTO.getDataList().stream().anyMatch(s->StringUtils.isBlank(s.getOid()) || StringUtils.isBlank(s.getLinkType()))){ |
| | | throw new VciBaseException("有数据的主键(或链接类型)没有值,无法删除"); |
| | | } |
| | | List<ClientLinkObject> clos = new ArrayList<>(); |
| | | List<LinkObject> clos = new ArrayList<>(); |
| | | VciBaseUtil.switchListForOracleIn(deleteLinkDataDTO.getDataList()).stream().forEach(linkModelDTOs->{ |
| | | Map<String,String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("oid",QueryOptionConstant.IN +"(" + VciBaseUtil.toInSql(linkModelDTOs.stream().map(BaseLinkModelDTO::getOid).toArray(String[]::new)) +")"); |
| | | List<ClientLinkObject> clientLinkObjects = loService.queryCLO(linkModelDTOs.get(0).getLinkType(), conditionMap); |
| | | if(!CollectionUtils.isEmpty(clientLinkObjects)){ |
| | | clos.addAll(clientLinkObjects); |
| | | List<LinkObject> LinkObjects = loService.queryCLO(linkModelDTOs.get(0).getLinkType(), conditionMap); |
| | | if(!CollectionUtils.isEmpty(LinkObjects)){ |
| | | clos.addAll(LinkObjects); |
| | | } |
| | | }); |
| | | if(CollectionUtils.isEmpty(clos)){ |
| | | throw new VciBaseException("使用主键没有在系统中找到链接类型的数据"); |
| | | } |
| | | Map<String,List<ClientLinkObject>> fromBtmGroups = clos.stream().collect(Collectors.groupingBy(s->s.getFromBTMName())); |
| | | Map<String,List<ClientLinkObject>> toBtmGroups = clos.stream().collect(Collectors.groupingBy(s->s.getToBTMName())); |
| | | Map<String,List<com.vci.client.bof.ClientBusinessObject>> fromBtmDataGroups = new HashMap<>(); |
| | | Map<String,List<com.vci.client.bof.ClientBusinessObject>> toBtmDataGroups = new HashMap<>(); |
| | | Map<String,List<LinkObject>> fromBtmGroups = clos.stream().collect(Collectors.groupingBy(s->s.fromBTName)); |
| | | Map<String,List<LinkObject>> toBtmGroups = clos.stream().collect(Collectors.groupingBy(s->s.toBTName)); |
| | | Map<String,List<BusinessObject>> fromBtmDataGroups = new HashMap<>(); |
| | | Map<String,List<BusinessObject>> toBtmDataGroups = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(fromBtmGroups)){ |
| | | fromBtmGroups.forEach((btmType,cloList)->{ |
| | | List<com.vci.client.bof.ClientBusinessObject> cbos = boService.selectCBOByOidCollection(cloList.stream().map(ClientLinkObject::getFromOid).collect(Collectors.toList()), btmType); |
| | | List<BusinessObject> cbos = boService.selectCBOByOidCollection(cloList.stream().map(clo -> clo.fromOid).collect(Collectors.toList()), btmType); |
| | | fromBtmDataGroups.put(btmType,cbos); |
| | | }); |
| | | } |
| | | if(!CollectionUtils.isEmpty(toBtmGroups)){ |
| | | toBtmGroups.forEach((btmType,cloList)->{ |
| | | List<com.vci.client.bof.ClientBusinessObject> cbos = boService.selectCBOByOidCollection(cloList.stream().map(ClientLinkObject::getToOid).collect(Collectors.toList()), btmType); |
| | | List<BusinessObject> cbos = boService.selectCBOByOidCollection(cloList.stream().map(clo -> clo.toOid).collect(Collectors.toList()), btmType); |
| | | toBtmDataGroups.put(btmType,cbos); |
| | | }); |
| | | } |
| | |
| | | if(attr.toLowerCase().startsWith(LO_FROM_PREFIX)){ |
| | | fromBtmDataGroups.forEach((btm,cbos)->{ |
| | | String attrNotPrefix = attr.substring(LO_FROM_PREFIX.length()); |
| | | if(!CollectionUtils.isEmpty(cbos) && cbos.stream().anyMatch(s->!attrValue.equalsIgnoreCase(s.getAttributeValue(attrNotPrefix)))){ |
| | | if(!CollectionUtils.isEmpty(cbos) && cbos.stream().anyMatch(s->!attrValue.equalsIgnoreCase(ObjectTool.getBOAttributeValue(s, attrNotPrefix)))){ |
| | | throw new VciBaseException("数据的内容不允许删除,{0}", new String[]{deleteLinkDataDTO.getCheckNotDeleteMsg()}); |
| | | } |
| | | }); |
| | | }else if(attr.toLowerCase().startsWith(LO_TO_PREFIX)){ |
| | | toBtmDataGroups.forEach((btm,cbos)->{ |
| | | String attrNotPrefix = attr.substring(LO_TO_PREFIX.length()); |
| | | if(!CollectionUtils.isEmpty(cbos) && cbos.stream().anyMatch(s->!attrValue.equalsIgnoreCase(s.getAttributeValue(attrNotPrefix)))){ |
| | | if(!CollectionUtils.isEmpty(cbos) && cbos.stream().anyMatch(s->!attrValue.equalsIgnoreCase(ObjectTool.getBOAttributeValue(s, attrNotPrefix)))){ |
| | | throw new VciBaseException("数据的内容不允许删除,{0}", new String[]{deleteLinkDataDTO.getCheckNotDeleteMsg()}); |
| | | } |
| | | }); |
| | | }else { |
| | | if (clos.stream().anyMatch(s -> attrValue.equalsIgnoreCase(s.getAttributeValue(attr)))) { |
| | | if (clos.stream().anyMatch(s -> attrValue.equalsIgnoreCase(ObjectTool.getLOAttributeValue(s,attr)))) { |
| | | throw new VciBaseException("数据的内容不允许删除,{0}", new String[]{deleteLinkDataDTO.getCheckNotDeleteMsg()}); |
| | | } |
| | | } |
| | |
| | | //链接类型本身一般不会有关联 |
| | | List<LinkObject> los = new ArrayList<>(); |
| | | clos.stream().forEach(clo->{ |
| | | los.add(clo.getLinkObject()); |
| | | los.add(clo); |
| | | }); |
| | | try { |
| | | platformClientUtil.getBOFactoryService().batchDeleteLinkObject(los.toArray(new LinkObject[0])); |
| | |
| | | if(deleteLinkDataDTO.isDeleteFromData()){ |
| | | fromBtmDataGroups.forEach((btm,cbos)->{ |
| | | try{ |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.stream().map(com.vci.client.bof.ClientBusinessObject::getBusinessObject).toArray(BusinessObject[] :: new),1); |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]), DeleteTypeEnum.OID_AND_TS.getValue()); |
| | | }catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | if(deleteLinkDataDTO.isDeleteToData()){ |
| | | toBtmDataGroups.forEach((btm,cbos)->{ |
| | | try{ |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.stream().map(com.vci.client.bof.ClientBusinessObject::getBusinessObject).toArray(BusinessObject[] :: new),1); |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),DeleteTypeEnum.OID_AND_TS.getValue()); |
| | | }catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | referConfigVO.setConditionMap(new HashMap<>()); |
| | | } |
| | | |
| | | List<com.vci.client.bof.ClientBusinessObject> cbos = null; |
| | | List<BusinessObject> cbos = null; |
| | | String oidFieldName = StringUtils.isNotBlank(referConfigVO.getParentUsedField())?referConfigVO.getParentUsedField():referConfigVO.getValueField(); |
| | | if(referConfigVO.isSelectAllLevel()) { |
| | | String parentOidSql = ""; |
| | |
| | | @Override |
| | | public List<Map<String,String>> getDataAttr(String btmname, String oid) { |
| | | VciBaseUtil.alertNotNull(btmname,"业务类型的信息",oid,"业务数据的主键"); |
| | | List<com.vci.client.bof.ClientBusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid)); |
| | | List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid)); |
| | | List<Map<String,String>> dataMap = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | cbos.stream().forEach(cbo->{ |
| | |
| | | } |
| | | return dataMap; |
| | | } |
| | | |
| | | /** |
| | | * 数据升版本/次,前端使用JSON提交 |
| | | * @param btmname 业务类型的信息 |
| | | * @param oid 业务数据的主键 |
| | | * @param type 1:版次对象;2:版本对象;3:主对象 |
| | | * @return 执行的结果 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteBusinessObject(String btmname, String oid, int type) throws PLException { |
| | | List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid)); |
| | | BaseResult<Object> objectBaseResult = new BaseResult<>(); |
| | | if(cbos.size() == 0){ |
| | | objectBaseResult.setSuccess(false); |
| | | throw new PLException("500", new String[]{"没有获取到数据的主键"}); |
| | | } |
| | | for (BusinessObject cbo : cbos) { |
| | | if(StringUtils.isBlank(cbo.revisionid)){ |
| | | String revisionoid = Arrays.stream(cbo.hisAttrValList).filter(e -> e.attrName.equals("REVISIONOID")).findFirst().map(e -> e.attrVal).orElse(""); |
| | | cbo.revisionid = revisionoid; |
| | | } |
| | | boolean b = platformClientUtil.getBOFService().deleteBusinessObject(cbo,type); |
| | | if(!b){ |
| | | throw new PLException("500", new String[]{"数据删除失败!!"}); |
| | | } |
| | | } |
| | | return BaseResult.success(); |
| | | } |
| | | /** |
| | | * 变更所有者 |
| | | * @param btmname 业务类型 |
| | | * @param oid 主键 |
| | | * @return 执行的结果 |
| | | */ |
| | | @Override |
| | | public BaseResult changeBusinessObjectOwner(String btmname, String oid) throws PLException { |
| | | List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid)); |
| | | BaseResult<Object> objectBaseResult = new BaseResult<>(); |
| | | if(cbos.size() == 0){ |
| | | objectBaseResult.setSuccess(false); |
| | | throw new PLException("500", new String[]{"没有获取到数据的主键"}); |
| | | } |
| | | UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByUserName(WebUtil.getCurrentUserId()); |
| | | for (BusinessObject cbo : cbos) { |
| | | platformClientUtil.getBOFService().changeBusinessObjectOwner(cbo,userInfo); |
| | | } |
| | | return BaseResult.success(); |
| | | } |
| | | /** |
| | | * 变更所有者 |
| | | * @param btmname 业务类型 |
| | | * @param oid 主键 |
| | | * @param releaseStatus 发布状态 |
| | | * @return 执行的结果 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public BaseResult transferBusinessObject(String btmname, String oid, String toStatus,String releaseStatus) throws PLException { |
| | | List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid)); |
| | | BaseResult<Object> objectBaseResult = new BaseResult<>(); |
| | | if(cbos.size() == 0){ |
| | | objectBaseResult.setSuccess(false); |
| | | throw new PLException("500", new String[]{"没有获取到数据的主键"}); |
| | | } |
| | | for (BusinessObject cbo : cbos) { |
| | | platformClientUtil.getBOFService().transferBusinessObjectAndRelease(cbo, toStatus, releaseStatus); |
| | | } |
| | | return BaseResult.success(); |
| | | } |
| | | } |