| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.vci.client.common.providers.ClientServiceProvider; |
| | | import com.vci.client.mw.ClientSessionUtility; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.atm.AttributeDef; |
| | | import com.vci.corba.omd.btm.BizType; |
| | | import com.vci.corba.omd.etm.EnumType; |
| | | import com.vci.corba.omd.lcm.Bound; |
| | | import com.vci.corba.omd.lcm.LifeCycle; |
| | | import com.vci.corba.omd.ltm.LinkType; |
| | | import com.vci.corba.omd.qtm.QTD; |
| | | import com.vci.corba.omd.stm.StatePool; |
| | | import com.vci.corba.omd.vrm.VersionRule; |
| | | import com.vci.dto.OsBtmTypeDTO; |
| | | import com.vci.dto.OsBtmTypeLinkAttributesDTO; |
| | | import com.vci.omd.constants.AttributeConstants; |
| | | import com.vci.omd.constants.FileObjectType; |
| | | import com.vci.omd.objects.OtherInfo; |
| | | import com.vci.pagemodel.*; |
| | | import com.vci.starter.web.annotation.log.VciUnLog; |
| | | import com.vci.starter.web.enumpck.BooleanEnum; |
| | |
| | | import com.vci.starter.web.util.BeanUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.VciDateUtil; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | | import com.vci.web.service.*; |
| | | import com.vci.web.util.ConcurrentDateFormat; |
| | | import com.vci.web.util.Func; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.swing.*; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | @Autowired(required = false) |
| | | @Lazy |
| | | private OsBtmServiceI self; |
| | | |
| | | /** |
| | | * 一些默认的表 |
| | | */ |
| | | private final List<String> tableList = Arrays.asList("pl_qtemplate", "PL_QTEMPLATEDEF", |
| | | "pl_typeright", "plcommandparameter", "plpagedefination", |
| | | "pluilayout", "pltabbutton", "pltabpage", "plportalvi", |
| | | "plreleasedobj"); |
| | | |
| | | /** |
| | | * workFlowTables 中的表有主外键关系,当表主键或唯一键被引用为外键时, |
| | | * 就算引用方没有数据, truncate还不是不能删除表中数据, 而 delete可以. |
| | | */ |
| | | private final List<String> workFlowTableList = Arrays.asList( |
| | | //流程(自定义表) |
| | | "PLPROCESSTEMPLATE", "PLPROCESSCATEGORY", "PLPROCESSTASK",//"PLRMTEMPLATEPROCESS", |
| | | "PLPROCESSTASKPROPERTY", "PLFLOWAPPROVEOPINION", "PLFLOWOBJECT", "PLFLOWINSTANCE", |
| | | "WORKFLOW_TASK_CC_TABLE", "PLTASKDESC", "PLTASKSASSIGNED", "JBPM_SUBPROCESSTEM", |
| | | "JBPM4_TASKANDUSERCONFIG", "PLREVOKEPOLICY", "JBPM4_TASKANDUSERCONFIGEX", |
| | | //流程(JBPM系统表) |
| | | "JBPM4_DEPLOYPROP", "JBPM4_HIST_DETAIL", "JBPM4_ID_MEMBERSHIP", "JBPM4_JOB", |
| | | "JBPM4_PARTICIPATION", "JBPM4_VARIABLE", "JBPM4_HIST_ACTINST", "JBPM4_HIST_VAR", |
| | | "JBPM4_ID_GROUP", "JBPM4_ID_USER", "JBPM4_LOB", "JBPM4_DEPLOYMENT", |
| | | "JBPM4_HIST_PROCINST", "JBPM4_HIST_TASK", "JBPM4_TASK", "JBPM4_SWIMLANE", |
| | | "JBPM4_EXECUTION", "JBPM4_PROPERTY"); |
| | | |
| | | /** |
| | | * 查询所有的业务类型 |
| | |
| | | vo.setAbstractFlag(btmItem.isAbstract); |
| | | vo.setImplClass(btmItem.implClass); |
| | | vo.setShape(btmItem.shape); |
| | | vo.setRevLevel(btmItem.revLevel); |
| | | vo.setRevisionRuleId(btmItem.revRuleName); |
| | | vo.setTableName(VciBaseUtil.getTableName(vo.getId())); |
| | | vo.setInputRevisionFlag(btmItem.revInput); |
| | | vo.setDelimiter(btmItem.delimiter); |
| | | if(StringUtils.isNotBlank(vo.getRevisionRuleId()) || vo.isInputRevisionFlag()){ |
| | | vo.setRevisionFlag(true); |
| | | } |
| | |
| | | ervo.setTabRelViewList(relationVOList); |
| | | return ervo; |
| | | } |
| | | |
| | | /** |
| | | * 获取所有业务类型(树形结构) |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult<List<Tree>> getTreeBizTypes() throws PLException { |
| | | public List<Tree> getTreeBizTypes() throws PLException { |
| | | List<Tree> rootTreeList = new ArrayList<>(); |
| | | BizType[] bizTypes = getBizTypes(""); |
| | | BizType btItem = null; |
| | |
| | | } |
| | | } |
| | | |
| | | return BaseResult.success(rootTreeList); |
| | | return rootTreeList; |
| | | } |
| | | |
| | | /** |
| | | * 获取所有业务类型名称集合 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> getAllBtmName() throws PLException { |
| | | BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes(""); |
| | | if(null != bizTypes && bizTypes.length > 0){ |
| | | return Arrays.stream(bizTypes).map(bizType -> bizType.name).collect(Collectors.toList()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取业务全部属性类型 |
| | | * @param btmName 业务类型名称 |
| | |
| | | osBtms.add(vo); |
| | | } |
| | | return osBtms; |
| | | } |
| | | |
| | | /** |
| | | * dto转do对象 |
| | | * @return |
| | | */ |
| | | private BizType dto2BizType(OsBtmTypeDTO dto){ |
| | | BizType bizType = new BizType(); |
| | | bizType.name =dto.getId(); |
| | | bizType.isAbstract = dto.isAbstractFlag(); |
| | | bizType.label = dto.getName(); |
| | | bizType.fName = dto.getfName(); |
| | | bizType.implClass = dto.getImplClass(); |
| | | bizType.shape = ""; |
| | | bizType.lifeCycle = dto.getLifeCycleId(); |
| | | List<String> lcList = Arrays.asList(dto.getSubLifeCycleId().split(",")); |
| | | if (lcList != null) { |
| | | bizType.lifeCycles = lcList.toArray(new String[0]); |
| | | } else { |
| | | bizType.lifeCycles = new String[0]; |
| | | } |
| | | bizType.description = dto.getDescription(); |
| | | bizType.revLevel = dto.getRevLevel(); |
| | | |
| | | bizType.revRuleName = dto.getRevisionRuleName(); |
| | | bizType.revInput = dto.isInputRevisionFlag(); |
| | | |
| | | bizType.delimiter = (dto.getDelimiter() == null ? "" : dto.getDelimiter()); |
| | | |
| | | bizType.verRuleName = Short.parseShort(dto.getRevisionRuleName()); |
| | | |
| | | //bizType.imageName = dto.get; |
| | | //List<String> attrIdList = dto.getAttributesDTOList().stream().map(OsBtmTypeLinkAttributesDTO::getId).collect(Collectors.toList()); |
| | | |
| | | bizType.apNameArray = dto.getApNameArray();//attrIdList.toArray(new String[attrIdList.size()]); |
| | | String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | bizType.creator = Func.isBlank(dto.getCreator()) ? userId:dto.getCreator(); |
| | | bizType.createTime = Func.isEmpty(dto.getCreateTime()) ? timeMillis:dto.getCreateTime().getTime(); |
| | | bizType.modifier = userId; |
| | | bizType.modifyTime = timeMillis; |
| | | return bizType; |
| | | } |
| | | |
| | | /** |
| | | * 创建新的业务类型 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public boolean addBtmType(OsBtmTypeDTO btmTypeDTO) throws PLException { |
| | | VciBaseUtil.alertNotNull(btmTypeDTO,"创建的业务类型对象"); |
| | | //业务类型名称检查 |
| | | checkName(btmTypeDTO.getId()); |
| | | //生命周期检查 |
| | | checkLifeCycle(btmTypeDTO); |
| | | //版本规则检查 |
| | | checkVersionInfo(btmTypeDTO); |
| | | BizType bizType = this.dto2BizType(btmTypeDTO); |
| | | return platformClientUtil.getBtmService().addBizType(bizType); |
| | | } |
| | | |
| | | /** |
| | | * 批量新增业务类型 |
| | | * @param bizTypes |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean addBtmTypes(List<BizType> bizTypes) { |
| | | VciBaseUtil.alertNotNull(bizTypes,"创建的业务类型对象列表"); |
| | | bizTypes.stream().forEach(bizType->{ |
| | | try { |
| | | platformClientUtil.getBtmService().addBizType(bizType); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | throw new VciBaseException(exceptionMessage); |
| | | } |
| | | }); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 检查业务类型名称是否合规 |
| | | * @param btmName |
| | | * @throws PLException |
| | | */ |
| | | private void checkName(String btmName) throws PLException { |
| | | if (Func.isBlank(btmName)) { |
| | | throw new PLException("500",new String[]{"业务类型名不能为空!"}); |
| | | } |
| | | |
| | | if (!btmName.matches("[a-z A-Z]*")) { |
| | | throw new PLException("500",new String[]{"业务类型名只能为英文字母!"}); |
| | | } |
| | | |
| | | int maxLength = platformClientUtil.getBtmService().getBTNameMaxLength(); |
| | | |
| | | if (btmName.length() > maxLength) { |
| | | throw new PLException("500",new String[]{"业务类型名长度不能超过" + maxLength}); |
| | | } |
| | | |
| | | if (platformClientUtil.getBtmService().checkRowIsExists(btmName)) { |
| | | throw new PLException("500",new String[]{"业务类型名已经存在"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 是否选择生命周期 |
| | | * |
| | | * @return |
| | | */ |
| | | private void checkLifeCycle(OsBtmTypeDTO btmTypeDTO) throws PLException { |
| | | if (Func.isBlank(btmTypeDTO.getLifeCycleId())) { |
| | | throw new PLException("500",new String[]{"生命周期不能为空"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 选择一级版本:必须选择或手工输入版本号规则; 选择二级版本:必须选择或手工输入版本号规则, (版次号已经默认选择). |
| | | * @return |
| | | */ |
| | | private void checkVersionInfo(OsBtmTypeDTO dto) throws PLException { |
| | | //需要手动输入版本时revisionRuleName不能为空 |
| | | if (dto.isInputRevisionFlag() && Func.isBlank(dto.getRevisionRuleName())) { |
| | | throw new PLException("500",new String[]{"版本号规则不能为空"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 版本机制修改: 仅允许类型从"不可修订"变更至"一级版本管理机制","二级版本管理机制进行调整"; "一级版本管理机制"变更至"二级版本管理机制"; |
| | | * 两种方式. |
| | | * @param dbBizType 当前修改前的业务类型(库中存储的) |
| | | * @param dto 当前修改业务类型 |
| | | * @throws PLException |
| | | */ |
| | | private void checkRevLevel(BizType dbBizType,OsBtmTypeDTO dto) throws PLException { |
| | | if (dbBizType.revLevel == 1 && dto.getRevLevel()==0) { |
| | | throw new PLException("500",new String[]{"版本变更错误:不能从一级变为不可修订"}); |
| | | } |
| | | |
| | | if (dbBizType.revLevel == 2 && (dto.getRevLevel() == 1 || dto.getRevLevel() == 0)) { |
| | | throw new PLException("500",new String[]{"版本变更错误:不能从二级变为一级或不可修订"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改业务类型 |
| | | * @param btmTypeDTO |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public boolean updateBtmType(OsBtmTypeDTO btmTypeDTO) throws PLException { |
| | | VciBaseUtil.alertNotNull(btmTypeDTO,"修改的业务类型对象"); |
| | | //检查生命周期是否合规 |
| | | checkLifeCycle(btmTypeDTO); |
| | | //查询数据库中的业务类型 |
| | | String id = btmTypeDTO.getId(); |
| | | BizType dbBizType = platformClientUtil.getBtmService().getBizTypeByName(id); |
| | | if(Func.isEmpty(dbBizType) || Func.isBlank(dbBizType.oid)){ |
| | | throw new PLException("500",new String[]{"当前修改的业务类型不存在!"}); |
| | | } |
| | | //检查版本规则修改是否合规 |
| | | checkRevLevel(dbBizType,btmTypeDTO); |
| | | checkVersionInfo(btmTypeDTO); |
| | | //处理业务类型下的属性 |
| | | List<String> lastAttrList = new ArrayList<>(Arrays.asList(btmTypeDTO.getApNameArray())); |
| | | //不能移除的属性 |
| | | String[] unRemovableFields = null; |
| | | List<String> unRemovableFields_ = null; |
| | | //需要移除的属性 |
| | | List<String> removableFields = null; |
| | | //修改前业务类型在数据库中已存在的所有属性 |
| | | String[] apNameArray = btmTypeDTO.getApNameArray(); |
| | | Set<String> dbApNameArray = Arrays.stream(dbBizType.apNameArray) |
| | | .collect(Collectors.toSet()); |
| | | //过滤出需要移除的属性 |
| | | removableFields = Arrays.stream(apNameArray) |
| | | .filter(ap -> !dbApNameArray.contains(ap)) // 过滤不在 dbApSet 中的元素 |
| | | .collect(Collectors.toList()); |
| | | // 当业务类型表中某属性已经有值, 不删除该属性, 将已经移除的属性添加回来 |
| | | unRemovableFields = platformClientUtil.getBtmService().getUnRemovableFields(id, removableFields.toArray(new String[0])); |
| | | if (removableFields.size() > 0) { |
| | | //检查业务类型是否具有实例 |
| | | if (this.hasInstanceByBtmName(id)) { |
| | | //业务类型已有实例, 只能删除没有数据的列 |
| | | if (unRemovableFields != null && unRemovableFields.length > 0) { |
| | | unRemovableFields_ = Arrays.asList(unRemovableFields); |
| | | for (int i = 0; i < removableFields.size(); i++) { |
| | | String abName = removableFields.get(i); |
| | | if (unRemovableFields_.contains(abName)) { |
| | | if (!lastAttrList.contains(abName)) { |
| | | lastAttrList.add(abName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | BizType bizType = dto2BizType(btmTypeDTO); |
| | | bizType.apNameArray = lastAttrList.toArray(new String[lastAttrList.size()]); |
| | | return platformClientUtil.getBtmService().updateBizType(bizType); |
| | | } |
| | | |
| | | /** |
| | | * 删除业务类型 |
| | | * @param btmTypeDTO |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public boolean deleteBtmType(OsBtmTypeDTO btmTypeDTO) throws PLException { |
| | | VciBaseUtil.alertNotNull(btmTypeDTO,"删除的业务类型"); |
| | | String btmName = btmTypeDTO.getId(); |
| | | //只能删除叶子节点 |
| | | if(Func.isNotBlank(btmTypeDTO.getfName())){ |
| | | throw new PLException("500",new String[]{"只能删除叶子节点"}); |
| | | } |
| | | // 业务类型被链接类型使用, 不能删除 |
| | | List<String> usedNameList = linkTypeService.getUsedBtmLinkList(btmName); |
| | | if (usedNameList != null && usedNameList.size() > 0) { |
| | | throw new PLException("500",new String[]{"该类型已被链接类型使用,禁止删除"}); |
| | | } |
| | | // 业务类型已经生成了业务对象, 不能删除 |
| | | if (hasInstanceByBtmName(btmName)) { |
| | | throw new PLException("500",new String[]{"该类型已有实例,禁止删除"}); |
| | | } |
| | | |
| | | BizType bizType = new BizType(); |
| | | bizType.ts = btmTypeDTO.getTs().getTime(); |
| | | bizType.oid = btmTypeDTO.getOid(); |
| | | bizType.name = btmTypeDTO.getId(); |
| | | return platformClientUtil.getBtmService().deleteBizType(bizType); |
| | | } |
| | | |
| | | /** |
| | | * 一致性检查 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public BaseResult checkBtmConsistency() throws PLException { |
| | | String[] result = platformClientUtil.getBtmService().btmConsistencyCheck(); |
| | | Map<String, String> dbCheckMap = new HashMap<String, String>(); |
| | | for(int i = 0; i < result.length; i++){ |
| | | String info = result[i]; |
| | | if(info.equals("")){ |
| | | continue; |
| | | } |
| | | String[] infos = info.split("/DML"); |
| | | String typeName = infos[0]; |
| | | String dml = infos[1]; |
| | | dbCheckMap.put(typeName, dml); |
| | | } |
| | | if(dbCheckMap.size() < 1){ |
| | | return BaseResult.successMsg("数据库中的表结构与类型一致,无需修复!!"); |
| | | }else{ |
| | | //需要修复时就需要界面唤起对话框进行处理 |
| | | List<Map> list = new ArrayList<>(); |
| | | list.add(dbCheckMap); |
| | | BaseResult<List<Map>> listBaseResult = BaseResult.dataList(200, list, "需要进行列的修复!!"); |
| | | listBaseResult.setSuccess(false); |
| | | return listBaseResult; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 一致性检查修复功能 |
| | | * @param repairData |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult executeRepair(String repairData) throws Exception { |
| | | Map<String, String> dbCheckMap = new ObjectMapper().readValue(repairData, new TypeReference<Map<String,String>>(){}); |
| | | List<String> list = this.getRepairDML(dbCheckMap); |
| | | if(list.size() < 1){ |
| | | return BaseResult.success(); |
| | | } |
| | | try { |
| | | String[] result = platformClientUtil.getBtmService().executeRepair(list.toArray(new String[0])); |
| | | return BaseResult.success(result); |
| | | }catch (PLException e){ |
| | | return BaseResult.fail("业务类型修复失败,原因:"+VciBaseUtil.getExceptionMessage(e)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建视图 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public boolean createView() throws PLException { |
| | | return platformClientUtil.getBtmService().createView(); |
| | | } |
| | | |
| | | /** |
| | | * 删除数据界面的查询 |
| | | * @return 业务类型,链接类型 |
| | | */ |
| | | @Override |
| | | public BaseResult getObjectData() throws PLException { |
| | | //获取业务类型名称集合 |
| | | List<String> allBtmName = this.getAllBtmName(); |
| | | //获取链接类型名称集合 |
| | | List<String> allLinkType = linkTypeService.getAllLtName(); |
| | | Map<String,List> map = new HashMap<>(); |
| | | map.put("btmType",allBtmName); |
| | | map.put("linkType",allLinkType); |
| | | map.put("table",tableList); |
| | | map.put("workFlow",workFlowTableList); |
| | | List<Map> list = new ArrayList<>(); |
| | | list.add(map); |
| | | return BaseResult.dataList(list); |
| | | } |
| | | |
| | | /** |
| | | * 删除数据 |
| | | * @param btmNames 业务类型名 |
| | | * @param linkNames 链接类型名 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public List<Map> truncateTable(String[] btmNames,String[] linkNames) throws PLException { |
| | | List<Map> returnMapList = new ArrayList<>(); |
| | | Map<String, List<String>> map = new HashMap<>(); |
| | | map.put("btmSuccess",new ArrayList<>()); |
| | | map.put("btmFail",new ArrayList<>()); |
| | | map.put("linkSuccess",new ArrayList<>()); |
| | | map.put("linkFail",new ArrayList<>()); |
| | | if(Func.isNotEmpty(btmNames)){ |
| | | for(int i = 0; i < btmNames.length; i++){ |
| | | String btName = btmNames[i]; |
| | | try { |
| | | if(platformClientUtil.getBtmService().truncateTable(btName)){ |
| | | //修改成功记录下成功的业务类型名 |
| | | map.get("btmSuccess").add(btName); |
| | | } |
| | | } catch (PLException e1) { |
| | | e1.printStackTrace(); |
| | | logger.error(VciBaseUtil.getExceptionMessage(e1)); |
| | | //修改失败记录下失败的业务类型名 |
| | | map.get("btmFail").add(btName); |
| | | } |
| | | } |
| | | } |
| | | if(Func.isNotEmpty(linkNames)){ |
| | | //truncate链接类型数据 |
| | | for(int i = 0; i < linkNames.length; i++){ |
| | | String ltName = linkNames[i]; |
| | | try { |
| | | if(platformClientUtil.getLinkTypeService().truncateTable(ltName)){ |
| | | map.get("linkSuccess").add(ltName); |
| | | } |
| | | } catch (PLException e1) { |
| | | e1.printStackTrace(); |
| | | logger.error(VciBaseUtil.getExceptionMessage(e1)); |
| | | map.get("linkFail").add(ltName); |
| | | } |
| | | } |
| | | } |
| | | returnMapList.add(map); |
| | | return returnMapList; |
| | | } |
| | | |
| | | /** |
| | | * 删除全部类型 |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public BaseResult deleteAllType() throws PLException { |
| | | DeleteType deleteType = new DeleteType(); |
| | | //获取待删除的业务类型 |
| | | List<BizType> delBtList = deleteType.getDelBtList(); |
| | | //获取待删除的链接类型 |
| | | List<LinkType> ltNames = deleteType.getDelLtList(); |
| | | //获取待删除的属性 |
| | | List<String> delAbList = deleteType.getDelAbList(); |
| | | //获取待删除的枚举类型 |
| | | List<EnumType> delEnumList = deleteType.getDelEnumList(); |
| | | //获取待删除的生命周期 |
| | | List<LifeCycle> delLCList = deleteType.getDelLCList(); |
| | | //获取待删除的状态 |
| | | List<StatePool> delStateList = deleteType.getDelSPList(); |
| | | //获取待删除的版本规则 |
| | | List<VersionRule> delVRList = deleteType.getDelVRList(); |
| | | try { |
| | | platformClientUtil.getBtmService().deleteBtsAndTables(delBtList.toArray(new BizType[0])); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除业务类型和对应表格时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | try { |
| | | ClientServiceProvider.getOMDService().getLinkTypeService().deleteLtsAndTables(ltNames.toArray(new LinkType[0])); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除链接类型时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | try { |
| | | AttributeDef[] abs = platformClientUtil.getAttributeService().getAttributeDefsByNames(delAbList.toArray(new String[0])); |
| | | platformClientUtil.getAttributeService().deleteAttributeDefs(abs); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除属性池属性时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | try { |
| | | platformClientUtil.getEnumService().deleteEnumTypes(delEnumList.toArray(new EnumType[0])); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除枚举类型时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | try { |
| | | platformClientUtil.getLifeCycleService().deleteLifeCycles(delLCList.toArray(new LifeCycle[0])); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除生命周期时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | try { |
| | | platformClientUtil.getStatePoolService().deleteStatePools(delStateList.toArray(new StatePool[0])); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除状态池状态时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | try { |
| | | platformClientUtil.getVersionService().deleteVersionRules(delVRList.toArray(new VersionRule[0])); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "清除版本规则时出现异常,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | return BaseResult.success("清除数据完成!"); |
| | | } |
| | | |
| | | /** |
| | | * 根据业务类型名称和其下的属性名称获取也有的索引 |
| | | * @param btmName |
| | | * @param attrName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> getIndexByBtmAndAttrName(String btmName, String attrName) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据业务类型名称和其下的属性名称删除索引 |
| | | * @param btmName |
| | | * @param attrName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean delIndexByBtmAndAttrName(String btmName, String attrName) { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 给业务类型下的指定属性新增索引 |
| | | * @param addMap 如:(btmName:part attrName:name indexName: PARTNAMEINDEX) |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean addIndex(Map<String, String> addMap) { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 获取需要修复的伪sql |
| | | * @param dbCheckMap |
| | | * @return |
| | | */ |
| | | private List<String> getRepairDML(Map<String, String> dbCheckMap) { |
| | | List<String> list = new ArrayList<String>(); |
| | | for(Iterator<String> ite = dbCheckMap.keySet().iterator(); ite.hasNext();){ |
| | | String type = ite.next(); |
| | | String dml = dbCheckMap.get(type); |
| | | list.add(type + "/DML" + dml); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 有实例:true 无实例:false |
| | | * |
| | | * @return |
| | | */ |
| | | private boolean hasInstanceByBtmName(String btmName) throws PLException { |
| | | //String tableName = OmdTools.getBTMTableName(btmName); |
| | | //boolean flag = DDLToolClient.getService().hasInstanceOralce(tableName); |
| | | boolean flag = false; |
| | | try { |
| | | flag = ClientServiceProvider.getOMDService().getBTMService().hasData(btmName); |
| | | } catch (PLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | throw new PLException("500",new String[]{exceptionMessage}); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | private List<Tree> getChildren(BizType[] bizTypes,BizType parentBIzType){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 封装删除全部类型相关的查询方法的内部类 |
| | | */ |
| | | private class DeleteType{ |
| | | |
| | | private List<String> exceptBts, exceptAbs, exceptEnums, exceptRev, exceptLCs, exceptStates; |
| | | |
| | | { |
| | | exceptBts.add("workitem"); |
| | | exceptBts.add(FileObjectType.FILE_DATA_TABLE); |
| | | } |
| | | |
| | | /** |
| | | * 获取需要删除的业务类型 |
| | | * @return |
| | | */ |
| | | public List<BizType> getDelBtList() throws PLException { |
| | | List<BizType> list = new ArrayList<>(); |
| | | BizType[] bts = platformClientUtil.getBtmService().getBizTypes(""); |
| | | for(BizType bt : bts){ |
| | | boolean exceptFlag = false; |
| | | for(String except : exceptBts){ |
| | | if(except.equalsIgnoreCase(bt.name)){ |
| | | exceptFlag = true; |
| | | break; |
| | | } |
| | | } |
| | | if(!exceptFlag){ |
| | | list.add(bt); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取需要删除的链接类型 |
| | | * @return |
| | | */ |
| | | public List<LinkType> getDelLtList() throws PLException { |
| | | LinkType[] linkTypes = platformClientUtil.getLinkTypeService().getLinkTypes(); |
| | | return Arrays.asList(linkTypes); |
| | | } |
| | | |
| | | /** |
| | | * 获取待删除的属性 |
| | | * @return |
| | | */ |
| | | public List<String> getDelAbList() { |
| | | List<String> list = new ArrayList<String>(); |
| | | AttributeDef[] attribItems = null; |
| | | try { |
| | | attribItems = platformClientUtil.getAttributeService().getAttributeDefs("", 0, 0); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //依据保留的类型构造保留的属性 |
| | | exceptAbs = new ArrayList<String>(); |
| | | for(String except : exceptBts){ |
| | | String[] btmApNameArray = null; |
| | | try { |
| | | btmApNameArray = platformClientUtil.getBtmService().getAttributeNames(except); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(btmApNameArray != null){ |
| | | for(String abName : btmApNameArray){ |
| | | if(!exceptAbs.contains(abName)){ |
| | | exceptAbs.add(abName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //构造可删除的属性 |
| | | if(attribItems != null){ |
| | | for(AttributeDef ab : attribItems){ |
| | | String abName = ab.name; |
| | | if(!exceptAbs.contains(abName)){ |
| | | list.add(abName); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取待删除的枚举类型 |
| | | * @return |
| | | */ |
| | | public List<EnumType> getDelEnumList() { |
| | | List<EnumType> list = new ArrayList<EnumType>(); |
| | | try { |
| | | //依据保留的类型构造保留的属性 |
| | | exceptEnums = new ArrayList<String>(); |
| | | EnumType[] emItems = ClientServiceProvider.getOMDService().getEnumService().getEnumTypes("", 0, 0); |
| | | AttributeDef[] abs = platformClientUtil.getAttributeService().getAttributeDefsByNames(exceptAbs.toArray(new String[0])); |
| | | for(AttributeDef ab : abs){ |
| | | OtherInfo otherInfo = OtherInfo.getOtherInfoByText(ab.other); |
| | | String enumName = otherInfo.getEnumName(); |
| | | if(enumName != null && !enumName.equals("") && !exceptEnums.contains(enumName)){ |
| | | exceptEnums.add(enumName); |
| | | } |
| | | } |
| | | for(EnumType em : emItems){ |
| | | if(!exceptEnums.contains(em.name)){ |
| | | list.add(em); |
| | | } |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取待删除的生命周期 |
| | | * @return |
| | | */ |
| | | public List<LifeCycle> getDelLCList(){ |
| | | List<LifeCycle> list = new ArrayList<LifeCycle>(); |
| | | exceptLCs = new ArrayList<String>(); |
| | | exceptStates = new ArrayList<String>(); |
| | | for(String btName : exceptBts){ |
| | | try { |
| | | BizType bt = platformClientUtil.getBtmService().getBizTypeByName(btName); |
| | | String lcName = bt.lifeCycle; |
| | | if(lcName != null && !lcName.equals("") && !exceptLCs.contains(lcName)){ |
| | | exceptLCs.add(lcName); |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | LifeCycle[] lcs = null; |
| | | try { |
| | | lcs = platformClientUtil.getLifeCycleService().getLifeCycles(); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(lcs != null){ |
| | | for(LifeCycle lc : lcs){ |
| | | String name = lc.name; |
| | | if(name != null && !name.equals("") && !exceptLCs.contains(name)){ |
| | | list.add(lc); |
| | | }else{ |
| | | //保留的状态池 |
| | | Bound[] bounds = lc.bounds; |
| | | for(Bound bound : bounds){ |
| | | String sName = bound.name; |
| | | exceptStates.add(sName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取待删除的状态 |
| | | * @return |
| | | */ |
| | | public List<StatePool> getDelSPList(){ |
| | | List<StatePool> list = new ArrayList<StatePool>(); |
| | | StatePool[] states = null; |
| | | try { |
| | | states = platformClientUtil.getStatePoolService().getStatePools(); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(states != null){ |
| | | for(StatePool state : states){ |
| | | String name = state.name; |
| | | if(name != null && !name.equals("") && !exceptStates.contains(name)){ |
| | | list.add(state); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取待删除的版本规则 |
| | | * @return |
| | | */ |
| | | public List<VersionRule> getDelVRList(){ |
| | | List<VersionRule> list = new ArrayList<VersionRule>(); |
| | | exceptRev = new ArrayList<String>(); |
| | | for(String btName : exceptBts){ |
| | | try { |
| | | BizType bt = platformClientUtil.getBtmService().getBizTypeByName(btName); |
| | | String revName = bt.revRuleName; |
| | | if(revName != null && !revName.equals("") && !exceptRev.contains(revName)){ |
| | | exceptRev.add(revName); |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | VersionRule[] revs = null; |
| | | try { |
| | | revs = platformClientUtil.getVersionService().getVersionRules(); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(revs != null){ |
| | | for(VersionRule rev : revs){ |
| | | String name = rev.name; |
| | | if(name != null && !name.equals("") && !exceptRev.contains(name)){ |
| | | list.add(rev); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |