| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.vci.client.omd.linktype.util.Tool; |
| | | import com.vci.client.omd.provider.BtmProvider; |
| | | import com.vci.client.omd.provider.LinkTypeProvider; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.atm.AttributeDef; |
| | | import com.vci.corba.omd.btm.BTMServicePrx; |
| | |
| | | import com.vci.corba.omd.lcm.TransitionVOEvent; |
| | | import com.vci.corba.omd.ltm.LinkType; |
| | | import com.vci.corba.omd.stm.StatePool; |
| | | import com.vci.dto.*; |
| | | import com.vci.pagemodel.*; |
| | | import com.vci.starter.poi.bo.WriteExcelData; |
| | | import com.vci.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | |
| | | import com.vci.starter.web.util.VciDateUtil; |
| | | import com.vci.starter.word.bo.WordMergeStartTableDataBO; |
| | | import com.vci.starter.word.util.WordUtil; |
| | | import com.vci.web.dto.*; |
| | | import com.vci.web.pageModel.*; |
| | | import com.vci.web.properties.OsDDLExportWordFieldProperties; |
| | | import com.vci.web.service.*; |
| | | import com.vci.web.util.Func; |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.client.omd.attribpool.ui.VTDataTypePanel.*; |
| | | import static com.vci.omd.constants.AttributeConstants.*; |
| | | |
| | | |
| | | /** |
| | |
| | | * @param statusDTOList 要导入的状态的数据传输对象列表 |
| | | * @throws VciBaseException 查询或者执行出错的时候会抛出异常 |
| | | */ |
| | | private void importStatus( Collection<OsStatusDTO> statusDTOList) throws VciBaseException{ |
| | | private void importStatus( Collection<OsStatusDTO> statusDTOList) throws Exception { |
| | | //要导入的状态的所有英文名称 |
| | | List<String> statusIdList = new ArrayList<String>(); |
| | | Iterator<OsStatusDTO> iterator = statusDTOList.iterator(); |
| | |
| | | * @param lifeCycleDTOList 要导入的生命周期数据传输对象列表 |
| | | * @throws VciBaseException 查询或者保存出错的时候,会抛出异常 |
| | | */ |
| | | private void importLifeCycles(Collection<OsLifeCycleDTO> lifeCycleDTOList) throws VciBaseException{ |
| | | private void importLifeCycles(Collection<OsLifeCycleDTO> lifeCycleDTOList) throws VciBaseException, PLException { |
| | | Set<String> existLifeCycleIds = lifeCycleService.selectAllLifeCycleMap().keySet(); |
| | | //生命周期的名称没有转为小写,但是平台又区分大小写 |
| | | List<String> existLifeCycleLowIds = existLifeCycleIds.stream().map(s->s.toLowerCase(Locale.ROOT)).collect(Collectors.toList()); |
| | |
| | | List<LifeCycle> unExistLifeCycleList = new ArrayList<LifeCycle>(); |
| | | List<LifeCycle> editLifeCycleList = new ArrayList<LifeCycle>(); |
| | | String userId = WebUtil.getCurrentUserId(); |
| | | long now = VciDateUtil.getTime(VciDateUtil.getNow()); |
| | | long now = VciDateUtil.getNowTime(); |
| | | //循环分析需要添加还是修改 |
| | | for(OsLifeCycleDTO lifeCycleDTO : lifeCycleDTOList){ |
| | | String lifeCycleId = lifeCycleDTO.getId().toLowerCase().trim(); |
| | |
| | | lifeCyle.ts = VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat); |
| | | lifeCyle.name = lifeCycleDTO.getId(); |
| | | }else { |
| | | lifeCyle = lifeCycleService.lifeCycleVO2DO( allLifeCycleLowMap.get(lifeCycleId)); |
| | | lifeCyle = lifeCycleService.lifeCycleVO2DO(allLifeCycleLowMap.get(lifeCycleId)); |
| | | edit = true; |
| | | } |
| | | lifeCyle.tag = lifeCycleDTO.getName(); |
| | |
| | | List<AttributeDef> unExistAttrList = new ArrayList<AttributeDef>(); |
| | | List<AttributeDef> editAttrList = new ArrayList<AttributeDef>(); |
| | | String userId = WebUtil.getCurrentUserId(); |
| | | long now = VciDateUtil.getTime(VciDateUtil.getNow()); |
| | | long now = VciDateUtil.getNowTime(); |
| | | //循环分析需要添加还是修改 |
| | | for (OsAttributeDTO attributeDTO : attributeDTOList) { |
| | | String attrId = attributeDTO.getId().toLowerCase().trim(); |
| | |
| | | List<BizType> unExistBtmList = new ArrayList<BizType>(); |
| | | List<BizType> editBtmList = new ArrayList<BizType>(); |
| | | String userId = WebUtil.getCurrentUserId(); |
| | | long now = VciDateUtil.getTime(VciDateUtil.getNow()); |
| | | long now = VciDateUtil.getNowTime(); |
| | | |
| | | for (OsBtmTypeDTO btmTypeDTO : btmTypeDTOList) { |
| | | String btmId = btmTypeDTO.getId().toLowerCase().trim(); |
| | |
| | | btmService.addBizType(btmItem); |
| | | //执行完成了需要创建表 |
| | | //获取的时候不一定刷新了缓存,这样就获取不到信息 |
| | | String btmTableName = BtmProvider.getInstance().getBTTableName(btmItem.name); |
| | | //OmdHelper |
| | | //todo 此占无法引用,后续会进行调整,再进行引用 |
| | | // String btmTableName = BtmProvider.getInstance().getBTTableName(btmItem.name); |
| | | String btmTableName = null; |
| | | String sql = "create Table " + btmTableName + "(" + "\n\tOID VARCHAR2(36) not null,\n\tREVISIONOID VARCHAR2(36),\n\tNAMEOID VARCHAR2(36),\n\tBtmName VARCHAR2(36),\n\tISLastR CHAR(1),\n\tISFirstR CHAR(1),\n\tISLastV CHAR(1),\n\tISFirstV CHAR(1),\n\tCreator VARCHAR2(36),\n\tCreateTime TIMESTAMP,\n\tLastModifier VARCHAR2(36),\n\tLastModifyTime TIMESTAMP,\n\tRevisionRule VARCHAR2(36),\n\tVersionRule VARCHAR2(36),\n\tRevisionSeq NUMBER,\n\tRevisionValue VARCHAR2(10),\n\tVersionSeq NUMBER,\n\tVersionValue VARCHAR2(10),\n\tLCTID VARCHAR2(36),\n\tLCStatus VARCHAR2(36),\n\tTS TIMESTAMP,\n\tID VARCHAR2(36),\n\tNAME VARCHAR2(128),\n\tDESCRIPTION VARCHAR2(255),\n\tOWNER VARCHAR2(36),\n\tCHECKINBY VARCHAR2(36),\n\tCHECKINTIME TIMESTAMP,\n\tCHECKOUTBY VARCHAR2(36),\n\tCHECKOUTTIME TIMESTAMP,\n\tCOPYFROMVERSION VARCHAR2(36),\n\t"; |
| | | String[] apNameArray = btmItem.apNameArray; |
| | | if(apNameArray!=null && apNameArray.length>0){ |
| | | for(String attrId : apNameArray){ |
| | | OsAttributeVO attrVO = attributeMap.get(attrId.toLowerCase().trim()); |
| | | if(attrVO!=null) { |
| | | String abSql = Tool.getInstance().getAbSql(attrService.attributeVO2DO(attrVO)); |
| | | sql = sql + abSql; |
| | | //todo 此占无法引用,后续会进行调整,再进行引用 |
| | | // String abSql = Tool.getInstance().getAbSql(attrService.attributeVO2DO(attrVO)); |
| | | // sql = sql + abSql; |
| | | }else{ |
| | | logger.info("业务类型{}里的属性{}没找到",btmTableName,attrId.toLowerCase().trim()); |
| | | } |
| | | } |
| | | } |
| | | String alterSql = BtmProvider.getInstance().getAddPKSql(btmItem.name); |
| | | // String alterSql = BtmProvider.getInstance().getAddPKSql(btmItem.name); |
| | | sql = sql.substring(0, sql.lastIndexOf(",")); |
| | | sql = sql + "\n)"; |
| | | //TODO 暂时不清楚用何种方式创建表,此处先注释掉 |
| | |
| | | OsBtmTypeAttributeVO idAttrVO = new OsBtmTypeAttributeVO(); |
| | | idAttrVO.setId("id"); |
| | | idAttrVO.setName("编号"); |
| | | idAttrVO.setAttrDataType(VciFieldTypeEnum.VTString.name()); |
| | | idAttrVO.setAttributeDataType(VciFieldTypeEnum.VTString.name()); |
| | | idAttrVO.setAttributeLength(50); |
| | | idAttrVO.setNullableFlag(true); |
| | | attributes.add(idAttrVO); |
| | |
| | | OsBtmTypeAttributeVO nameAttrVO = new OsBtmTypeAttributeVO(); |
| | | nameAttrVO.setId("name"); |
| | | nameAttrVO.setName("名称"); |
| | | nameAttrVO.setAttrDataType(VciFieldTypeEnum.VTString.name()); |
| | | nameAttrVO.setAttributeDataType(VciFieldTypeEnum.VTString.name()); |
| | | nameAttrVO.setAttributeLength(50); |
| | | nameAttrVO.setNullableFlag(true); |
| | | attributes.add(nameAttrVO); |
| | |
| | | OsBtmTypeAttributeVO descAttrVO = new OsBtmTypeAttributeVO(); |
| | | descAttrVO.setId("description"); |
| | | descAttrVO.setName("描述"); |
| | | descAttrVO.setAttrDataType(VciFieldTypeEnum.VTString.name()); |
| | | descAttrVO.setAttributeDataType(VciFieldTypeEnum.VTString.name()); |
| | | descAttrVO.setAttributeLength(150); |
| | | descAttrVO.setNullableFlag(true); |
| | | attributes.add(descAttrVO); |
| | |
| | | |
| | | attributes.stream().forEach( t -> { |
| | | int index = indexMap.get("index"); |
| | | Map<String,Object> columnData = attributeToWordMap(t,index); |
| | | Map<String,Object> columnData = null; |
| | | try { |
| | | columnData = attributeToWordMap(t,index); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "将属性对象拷贝到word数据对象中时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | } |
| | | indexMap.put("index",index+1); |
| | | columnDataList.add(columnData); |
| | | }); |
| | |
| | | indexMap.put("index",1); |
| | | attributes.stream().forEach( t -> { |
| | | int index = indexMap.get("index"); |
| | | Map<String,Object> columnData = attributeToWordMap(t,index); |
| | | Map<String,Object> columnData = null; |
| | | try { |
| | | columnData = attributeToWordMap(t,index); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "将属性对象拷贝到word数据对象中时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | } |
| | | indexMap.put("index",index+1); |
| | | columnDataList.add(columnData); |
| | | }); |
| | |
| | | if(!CollectionUtils.isEmpty(btmTypeVOList)) { |
| | | btmTypeVOList.stream().forEach(btmTypeVO -> { |
| | | String btmId = btmTypeVO.getId(); |
| | | List<OsBtmTypeAttributeVO> attributeVOS = btmService.listAttributeByBtmId(btmId); |
| | | List<OsBtmTypeAttributeVO> attributeVOS = null; |
| | | try { |
| | | attributeVOS = btmService.listAttributeByBtmId(btmId); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | throw new VciBaseException(VciBaseUtil.getExceptionMessage(e)); |
| | | } |
| | | //先是名称 |
| | | int rowIndex = index[0]; |
| | | WriteExcelData idED = new WriteExcelData(rowIndex, 0, btmId); |
| | |
| | | //然后属性的中文名称 |
| | | rowDataList.add(new WriteExcelData(rowIndex, 3, attributeVO.getName())); |
| | | //属性的类型 |
| | | rowDataList.add(new WriteExcelData(rowIndex, 4, VciFieldTypeEnum.getTextByValue(attributeVO.getAttrDataType()))); |
| | | rowDataList.add(new WriteExcelData(rowIndex, 4, VciFieldTypeEnum.getTextByValue(attributeVO.getAttributeDataType()))); |
| | | //是否可以为空 |
| | | rowDataList.add(new WriteExcelData(rowIndex, 5, attributeVO.isNullableFlag() ? "是" : "否")); |
| | | //属性长度 |
| | |
| | | if(!CollectionUtils.isEmpty(linkTypeVOList)){ |
| | | linkTypeVOList.stream().forEach(linkTypeVO->{ |
| | | String linkTypeId = linkTypeVO.getId(); |
| | | List<OsLinkTypeAttributeVO> attributeVOS = linkTypeService.listAttributeByLinkId(linkTypeId); |
| | | List<OsLinkTypeAttributeVO> attributeVOS = null; |
| | | try { |
| | | attributeVOS = linkTypeService.listAttributeByLinkId(linkTypeId); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | String errorLog = "查询链接类型时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorLog); |
| | | throw new VciBaseException(errorLog); |
| | | } |
| | | //先是名称 |
| | | int rowIndex = index[0]; |
| | | WriteExcelData idED = new WriteExcelData(rowIndex, 0, linkTypeId); |
| | |
| | | * @param index 索引 |
| | | * @return 数据映射,key 是word里的域字段,value是对应的值 |
| | | */ |
| | | private Map<String,Object> attributeToWordMap(OsBtmTypeAttributeVO btmTypeAttributeVO,int index){ |
| | | private Map<String,Object> attributeToWordMap(OsBtmTypeAttributeVO btmTypeAttributeVO,int index) throws PLException { |
| | | Map<String,Object> columnData = new HashMap<>(); |
| | | if(StringUtils.isNotBlank(wordFieldProperties.getColumnIndex())) { |
| | | columnData.put(wordFieldProperties.getColumnIndex(), index); |
| | | } |
| | | columnData.put(wordFieldProperties.getColumnId(),btmTypeAttributeVO.getId().toLowerCase()); |
| | | columnData.put(wordFieldProperties.getColumnName(),btmTypeAttributeVO.getName()); |
| | | String attrDataType = btmTypeAttributeVO.getAttrDataType(); |
| | | String attrDataType = btmTypeAttributeVO.getAttributeDataType(); |
| | | String columnType = VciFieldTypeEnum.getTextByValue(attrDataType); |
| | | if(StringUtils.isBlank(columnType)){ |
| | | columnType = "字符串"; |
| | |
| | | */ |
| | | private void addAttrToDB(Collection<String> addedAbList,String btmType,boolean linkType){ |
| | | if (!CollectionUtils.isEmpty(addedAbList)) { |
| | | String tableName = linkType? LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTTableName(btmType); |
| | | //todo 此暂无法引用,后续会进行调整,再进行引用 |
| | | // String tableName = linkType? LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTTableName(btmType); |
| | | String tableName = null; |
| | | String addSql = "alter table " + tableName + " add("; |
| | | Map<String, OsAttributeVO> attributeMap = attrService.selectAllAttributeMap(); |
| | | for (String abName : addedAbList) { |
| | | AttributeDef abItem = attrService.attributeVO2DO(attributeMap.get(abName)); |
| | | addSql = addSql + Tool.getInstance().getAbSql(abItem); |
| | | //todo 此暂无法引用,后续会进行调整,再进行引用 |
| | | // addSql = addSql + Tool.getInstance().getAbSql(abItem); |
| | | } |
| | | addSql = VciBaseUtil.removeComma(addSql.replace("\n\t","")); |
| | | addSql = addSql + ")"; |
| | |
| | | */ |
| | | private void removeAttrToDB(Collection<String> removeAbList,String btmType,boolean linkType){ |
| | | if (!CollectionUtils.isEmpty(removeAbList)) { |
| | | String tableName = linkType?LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTTableName(btmType); |
| | | String removeSql = "alter table " + tableName + " drop("; |
| | | for (String abName : removeAbList) { |
| | | removeSql = removeSql + abName + ","; |
| | | } |
| | | removeSql = VciBaseUtil.removeComma(removeSql.replace("\n\t","")); |
| | | removeSql = removeSql + ")"; |
| | | //todo 此暂无法引用,后续会进行调整,再进行引用 |
| | | // String tableName = linkType?LinkTypeProvider.getInstance().getLTTableName(btmType):BtmProvider.getInstance().getBTTableName(btmType); |
| | | // String removeSql = "alter table " + tableName + " drop("; |
| | | // for (String abName : removeAbList) { |
| | | // removeSql = removeSql + abName + ","; |
| | | // } |
| | | // removeSql = VciBaseUtil.removeComma(removeSql.replace("\n\t","")); |
| | | // removeSql = removeSql + ")"; |
| | | //TODO 不清楚具体使用什么方法,暂时注释,但不要删除 |
| | | // DDLToolClient.getService().batchExecuteUpdateOracle(new String[]{removeSql}); |
| | | } |
| | |
| | | } else { |
| | | btmItem.verRuleName = 0; |
| | | } |
| | | //包含的属性的数组 |
| | | List<OsBtmTypeLinkAttributesDTO> attributesDTOList = btmTypeDTO.getAttributesDTOList(); |
| | | List<String> attrIdList = new ArrayList<String>(); |
| | | if (!CollectionUtils.isEmpty(attributesDTOList)) { |
| | | for (OsBtmTypeLinkAttributesDTO attr : attributesDTOList) { |
| | | attrIdList.add(attr.getId().toLowerCase()); |
| | | } |
| | | } |
| | | btmItem.apNameArray = attrIdList.toArray(new String[0]); |
| | | //包含的属性名称 |
| | | btmItem.apNameArray = btmTypeDTO.getApNameArray().split(","); |
| | | } |
| | | |
| | | /** |
| | |
| | | List<LinkType> addLinkTypeList = new ArrayList<LinkType>(); |
| | | List<LinkType> editLinkTypeList = new ArrayList<LinkType>(); |
| | | String userId = WebUtil.getCurrentUserId(); |
| | | long now = VciDateUtil.getTime(VciDateUtil.getNow()); |
| | | long now = VciDateUtil.getNowTime(); |
| | | for(OsLinkTypeDTO linkTypeDTO : linkTypeDTOS){ |
| | | String linkId = linkTypeDTO.getId().toLowerCase().trim(); |
| | | LinkType linkType = null; |
| | |
| | | for(LinkType linkType : linkTypes){ |
| | | try{ |
| | | platformClientUtil.getLinkTypeService().addLinkType(linkType); |
| | | String tableName = LinkTypeProvider.getInstance().getLTTableName(linkType.name); |
| | | //todo 此暂无法引用,后续会进行调整,再进行引用 |
| | | // String tableName = LinkTypeProvider.getInstance().getLTTableName(linkType.name); |
| | | String tableName = null; |
| | | String sql = "create table " + tableName + "(" + "\n\tOID VARCHAR2(36) not null,\n\tCreator VARCHAR2(36),\n\tCreateTime TIMESTAMP,\n\tLastModifier VARCHAR2(36),\n\tLastModifyTime TIMESTAMP,\n\tTS TIMESTAMP,\n\t"; |
| | | String[] apNameArray = linkType.attributes; |
| | | if(apNameArray!=null && apNameArray.length>0){ |
| | | for(String attrId : apNameArray){ |
| | | OsAttributeVO attrVO = attributeMap.get(attrId.toLowerCase().trim()); |
| | | String abSql = Tool.getInstance().getAbSql(attrService.attributeVO2DO(attrVO)); |
| | | sql = sql + abSql; |
| | | //todo 此暂无法引用,后续会进行调整,再进行引用 |
| | | // String abSql = Tool.getInstance().getAbSql(attrService.attributeVO2DO(attrVO)); |
| | | // sql = sql + abSql; |
| | | } |
| | | } |
| | | sql = sql.substring(0, sql.lastIndexOf(",")); |