| | |
| | | } |
| | | |
| | | /** |
| | | * 创建链接类型的表格 |
| | | * |
| | | * @param linkTypeVO 链接类型的显示对象 |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | private void createDbTableForLink(LinkTypeVO linkTypeVO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(linkTypeVO, "要创建表格所属的业务类型", linkTypeVO.getTableName(), "业务类型的表格名称"); |
| | | String tableName = linkTypeVO.getTableName(); |
| | | if (!checkTableExistByTableName(tableName)) { |
| | | String attributeSql = getCreateSqlByAttributeForLink(linkTypeVO.getAttributes()); |
| | | dllMapper.createTableBySql(tableName, attributeSql); |
| | | if (StringUtils.isNotBlank(linkTypeVO.getName())) { |
| | | dllMapper.commentTable(tableName, linkTypeVO.getName()); |
| | | } |
| | | linkTypeVO.getAttributes().forEach(s -> { |
| | | dllMapper.commentColumnTable(tableName, s.getId(), s.getName()); |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * 获取创建的sql语句中属性部分 |
| | | * |
| | | * @param attributeVOList 属性的立碑 |
| | |
| | | attributeVOList.forEach(a -> { |
| | | sb.append(a.getId()).append(StringPool.SPACE); |
| | | VciFieldTypeEnum fieldTypeEnum = VciFieldTypeEnum.forValue(a.getAttrDataType()); |
| | | sb.append(dllMapper.getColumnTypeSql(fieldTypeEnum, a)); |
| | | sb.append(dllMapper.getColumnTypeSql(fieldTypeEnum, a)).append(","); |
| | | }); |
| | | return sb.substring(0, sb.lastIndexOf(",")); |
| | | } |
| | | |
| | | /** |
| | | * 获取创建的sql语句中属性部分 |
| | | * |
| | | * @param attributeVOList 属性的立碑 |
| | | * @return sql语句 |
| | | */ |
| | | @Override |
| | | public String getCreateSqlByAttributeForLink(List<LinkTypeAttributeVO> attributeVOList) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | attributeVOList.forEach(a -> { |
| | | BtmTypeAttributeVO attributeVO = Optional.ofNullable(BeanUtil.copy(a, BtmTypeAttributeVO.class)).orElseGet(BtmTypeAttributeVO::new); |
| | | attributeVO.setPkBtmType(a.getPkLinkType()); |
| | | sb.append(a.getId()).append(StringPool.SPACE); |
| | | VciFieldTypeEnum fieldTypeEnum = VciFieldTypeEnum.forValue(a.getAttrDataType()); |
| | | sb.append(dllMapper.getColumnTypeSql(fieldTypeEnum, attributeVO)).append(","); |
| | | }); |
| | | return sb.substring(0, sb.lastIndexOf(",")); |
| | | } |
| | |
| | | @Override |
| | | public void createDbTablesById(String ids) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(ids, "业务类型/链接类型的英文集合"); |
| | | List<BtmTypeVO> btmTypeVOList = BtmTypeCache.selectByIdCollection(VciBaseUtil.str2List(ids)); |
| | | // List<OsLinkTypeVO> linkTypeVOList = linkTypeService.listLinkTypeByIdCollection(VciBaseUtil.str2List(ids)); |
| | | if (!CollectionUtils.isEmpty(btmTypeVOList)) { |
| | | //说明是业务类型 |
| | | btmTypeVOList.forEach(this::createDbTableForBtm); |
| | | } |
| | | /*//试试链接类型 |
| | | if(!CollectionUtils.isEmpty(linkTypeVOList)){ |
| | | //的确是链接类型 |
| | | linkTypeVOList.stream().forEach( s -> { |
| | | createDbTableForLink(s); |
| | | }); |
| | | }*/ |
| | | // 业务类型 |
| | | Func.toStrList(",",ids).stream().filter(idBtmMap::containsKey).map(idBtmMap::get).forEach(this::createDbTableForBtm); |
| | | // 链接类型 |
| | | Func.toStrList(",",ids).stream().filter(idLinkMap::containsKey).map(idLinkMap::get).forEach(this::createDbTableForLink); |
| | | } |
| | | |
| | | /** |
| | |
| | | modifyAttributeInfo.setBeforeModifyAttributes(String.join(",", beforeList)); |
| | | } |
| | | } |
| | | modifyAttributeInfoDOList.add(modifyAttributeInfo); |
| | | }); |
| | | return modifyAttributeInfoDOList; |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | modifyAttributeInfoDOList.add(modifyAttributeInfo); |
| | | }); |
| | | return modifyAttributeInfoDOList; |
| | | } |
| | |
| | | @Override |
| | | public void reflexDifferent(List<ModifyAttributeInfo> differentAttributeList, List<BtmTypeVO> btmTypeVOList, List<LinkTypeVO> linkTypeVOList) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(differentAttributeList, "要清理的数据库的信息为空"); |
| | | Map<String, BtmTypeVO> idBtmTypeMap = btmTypeVOList.stream().collect(Collectors.toMap(BtmTypeVO::getId, t -> t, (o1, o2) -> o1)); |
| | | Map<String, LinkTypeVO> idLinkTypeMap = linkTypeVOList.stream().collect(Collectors.toMap(LinkTypeVO::getId, t -> t, (o1, o2) -> o1)); |
| | | Map<String, BtmTypeVO> idBtmTypeMap = Optional.ofNullable(btmTypeVOList).orElseGet(ArrayList::new).stream().collect(Collectors.toMap(BtmTypeVO::getId, t -> t, (o1, o2) -> o1)); |
| | | Map<String, LinkTypeVO> idLinkTypeMap = Optional.ofNullable(linkTypeVOList).orElseGet(ArrayList::new).stream().collect(Collectors.toMap(LinkTypeVO::getId, t -> t, (o1, o2) -> o1)); |
| | | differentAttributeList.forEach(s -> { |
| | | // BtmTypeVO btmType = idBtmTypeMap.get(id); |
| | | if (ModifyTableTaskEnum.CREATE.getValue().equalsIgnoreCase(s.getTaskName())) { |