| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.vci.client.common.providers.ClientServiceProvider; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.corba.omd.data.LinkObject; |
| | | import com.vci.corba.omd.data.RevisionDataInfo; |
| | | import com.vci.corba.omd.data.VersionDataInfo; |
| | | 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上的数据查询 |
| | |
| | | * @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(); |
| | | } |
| | |
| | | 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(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); |
| | | } |
| | |
| | | }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); |
| | | } |
| | |
| | | * @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<BusinessObject> 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.getBOFService().createBusinessObject(resultCbo.getObj(),formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion()); |
| | | BusinessObject afterCbo = new BusinessObject(); |
| | | afterCbo = bo; |
| | | result.setObj(boService.cbo2Map(afterCbo)); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){ |
| | | fileObjectService.releasedFile(resultCbo.getObj().btName,resultCbo.getObj().oid,formDataDTO.getReleaseFileOids()); |
| | | } |
| | | BaseResult<Map<String, Object>> result = BaseResult.success(); |
| | | result.setObj(boService.cbo2Map(businessObject)); |
| | | //后置事件 |
| | | String afterEvent = formDataDTO.getPostEvent(); |
| | | try { |
| | | callPostEvent(Arrays.stream(new BusinessObject[]{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); |
| | | } |
| | |
| | | throw new VciBaseException(formLinkDataDTO.isDirection()?"from端":"to端" + "的业务类型为空"); |
| | | } |
| | | |
| | | //查询from端的 |
| | | BusinessObject fromCbo = new BusinessObject(); |
| | | try { |
| | | fromCbo = platformClientUtil.getBOFService().readBusinessObject(fromOid,fromBtmName); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | String finalPrefix = prefix; |
| | | formLinkDataDTO.getData().forEach((key, value)->{ |
| | | if(key.toLowerCase().startsWith(finalPrefix)){ |
| | |
| | | return BaseResult.fail(resultClo.getMsg(),resultClo.getMsgObjs()); |
| | | } |
| | | clo = resultClo.getObj(); |
| | | if(StringUtils.isBlank(clo.toOid)){ |
| | | clo.toOid = toCbo.oid; |
| | | } |
| | | //执行保存 |
| | | BusinessObject[] bos = new BusinessObject[1]; |
| | | ObjectTool.dealBusinessObjectNullValue(toCbo); |
| | | ObjectTool.dealLinkObjectNullValue(clo); |
| | | bos[0] = toCbo; |
| | | try { |
| | | platformClientUtil.getBOFService().createBusinessObjectWithLink(bos,clo); |
| | |
| | | if(editFlag){ |
| | | try { |
| | | LinkObject linkObject = platformClientUtil.getBOFService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType()); |
| | | clo = new LinkObject(); |
| | | clo = linkObject; |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | |
| | | 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(); |
| | | } |
| | | // |
| | | LinkObject finalClo = clo; |
| | |
| | | if (ruleVO == null || StringUtils.isBlank(ruleVO.getOid())) { |
| | | throw new VciBaseException("{0}里的版本规则设置得不正确,在系统中没有找到{1}这个版本规则", new String[]{btmTypeVO.getName(), btmTypeVO.getRevisionRuleId()}); |
| | | } |
| | | cbo.revisionValue = ruleVO.getStartCode(); |
| | | cbo.revisionValue = ruleVO.getInitialValue(); |
| | | } |
| | | if (StringUtils.isBlank(cbo.nameoid)) { |
| | | cbo.nameoid = VciBaseUtil.getPk(); |
| | |
| | | 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<>(); |
| | |
| | | if(deleteLinkDataDTO.isDeleteFromData()){ |
| | | fromBtmDataGroups.forEach((btm,cbos)->{ |
| | | try{ |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),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.toArray(new BusinessObject[0]),1); |
| | | platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),DeleteTypeEnum.OID_AND_TS.getValue()); |
| | | }catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | } |
| | | 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(); |
| | | } |
| | | } |