| | |
| | | package com.vci.ubcs.ddl.service.impl; |
| | | |
| | | <<<<<<< HEAD |
| | | import com.alibaba.nacos.client.naming.NacosNamingService; |
| | | |
| | | ======= |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | >>>>>>> dd3a6c681f938fd53d5f6cc3a4fcee40e71b259c |
| | | import com.vci.starter.word.bo.WordMergeStartTableDataBO; |
| | | import com.vci.ubcs.ddl.bo.DdlTableBO; |
| | | import com.vci.ubcs.ddl.bo.DdlTableInDataBaseBO; |
| | |
| | | import com.vci.ubcs.ddl.properties.DdlExportWordFieldProperties; |
| | | import com.vci.ubcs.ddl.properties.DdlPropertise; |
| | | import com.vci.ubcs.ddl.service.IDdlService; |
| | | import com.vci.ubcs.omd.cache.OmdBtmTypeCache; |
| | | import com.vci.ubcs.omd.dto.OmdBtmTypeDTO; |
| | | import com.vci.ubcs.omd.entity.OsModifyAttributeInfoDO; |
| | | import com.vci.ubcs.omd.vo.OmdBtmTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.OmdBtmTypeVO; |
| | | import com.vci.ubcs.omd.vo.OsLinkTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.OsLinkTypeVO; |
| | | import com.vci.ubcs.omd.cache.BtmTypeCache; |
| | | import com.vci.ubcs.omd.dto.BtmTypeDTO; |
| | | import com.vci.ubcs.omd.entity.ModifyAttributeInfoDO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.omd.vo.LinkTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.LinkTypeVO; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | @Override |
| | | public String getTableNameByBtmTypeOid(String pkBtmType) { |
| | | VciBaseUtil.alertNotNull(pkBtmType, "业务类型或者链接类型的主键"); |
| | | OmdBtmTypeVO btmType = OmdBtmTypeCache.getDetail(pkBtmType); |
| | | BtmTypeVO btmType = BtmTypeCache.getDetail(pkBtmType); |
| | | String tableName = ""; |
| | | if (btmType == null || StringUtils.isBlank(btmType.getOid())) { |
| | | /*OsLinkTypeDO linkTypeDO = linkTypeDOMapper.selectByPrimaryKey(pkBtmType.trim()); |
| | |
| | | @Override |
| | | public String getTableNameByBtmTypeId(String id) { |
| | | VciBaseUtil.alertNotNull(id, "业务类型或者链接类型的英文名称"); |
| | | List<OmdBtmTypeVO> btmTypeList = OmdBtmTypeCache.selectByIdCollection(VciBaseUtil.str2List(id)); |
| | | List<BtmTypeVO> btmTypeList = BtmTypeCache.selectByIdCollection(VciBaseUtil.str2List(id)); |
| | | String tableName = ""; |
| | | if (CollectionUtils.isEmpty(btmTypeList)) { |
| | | /*List<OsLinkTypeDO> linkTypeDOList = linkTypeDOMapper.selectByIdCollection(VciBaseUtil.str2List(id)); |
| | |
| | | @Override |
| | | public void createDbTablesByOidCollection(Collection<String> oidCollection) throws VciBaseException { |
| | | VciBaseUtil.alertCollectionNotNull("业务类型/链接类型的主键集合", oidCollection); |
| | | List<OmdBtmTypeVO> btmTypeVOList = OmdBtmTypeCache.listBtmTypeByOidCollection(oidCollection); |
| | | List<BtmTypeVO> btmTypeVOList = BtmTypeCache.listBtmTypeByOidCollection(oidCollection); |
| | | // List<OsLinkTypeVO> linkTypeVOList = linkTypeService.listLinkTypeByOidCollection(oidCollection); |
| | | if (!CollectionUtils.isEmpty(btmTypeVOList)) { |
| | | //说明是业务类型 |
| | |
| | | * @param btmTypeVO 业务类型的显示对象 |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | private void createDbTableForBtm(OmdBtmTypeVO btmTypeVO) throws VciBaseException { |
| | | private void createDbTableForBtm(BtmTypeVO btmTypeVO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(btmTypeVO, "要创建表格所属的业务类型", btmTypeVO.getTableName(), "业务类型的表格名称"); |
| | | if (btmTypeVO.isViewFlag() && StringUtils.isNotBlank(btmTypeVO.getViewCreateSql())) { |
| | | //说明是视图 |
| | |
| | | @Override |
| | | public void createDbTablesById(String ids) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(ids, "业务类型/链接类型的英文集合"); |
| | | List<OmdBtmTypeVO> btmTypeVOList = OmdBtmTypeCache.selectByIdCollection(VciBaseUtil.str2List(ids)); |
| | | List<BtmTypeVO> btmTypeVOList = BtmTypeCache.selectByIdCollection(VciBaseUtil.str2List(ids)); |
| | | // List<OsLinkTypeVO> linkTypeVOList = linkTypeService.listLinkTypeByIdCollection(VciBaseUtil.str2List(ids)); |
| | | if (!CollectionUtils.isEmpty(btmTypeVOList)) { |
| | | //说明是业务类型 |
| | |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public void changeColumnForBtm(List<OmdBtmTypeAttributeVO> modifyLengthAttrVOList) throws VciBaseException { |
| | | public void changeColumnForBtm(List<BtmTypeAttributeVO> modifyLengthAttrVOList) throws VciBaseException { |
| | | VciBaseUtil.alertCollectionNotNull("要修改长度的属性集", modifyLengthAttrVOList); |
| | | Map<String, List<OmdBtmTypeAttributeVO>> btmTypeHasAttributeVOMap = modifyLengthAttrVOList.stream().collect(Collectors.groupingBy(OmdBtmTypeAttributeVO::getPkBtmType)); |
| | | Map<String, List<BtmTypeAttributeVO>> btmTypeHasAttributeVOMap = modifyLengthAttrVOList.stream().collect(Collectors.groupingBy(BtmTypeAttributeVO::getPkBtmType)); |
| | | btmTypeHasAttributeVOMap.forEach((k, v) -> { |
| | | OmdBtmTypeVO btmTypeVO = OmdBtmTypeCache.getDetail(k); |
| | | BtmTypeVO btmTypeVO = BtmTypeCache.getDetail(k); |
| | | if (btmTypeVO == null || StringUtils.isBlank(btmTypeVO.getOid())) { |
| | | throw new VciBaseException("要修改属性列长度的业务类型不存在"); |
| | | } |
| | |
| | | * @param tableName 表格的名称 |
| | | * @param attributeVOList 要添加的属性字段 |
| | | */ |
| | | private void changeColumnsForTable(String tableName, List<OmdBtmTypeAttributeVO> attributeVOList) { |
| | | private void changeColumnsForTable(String tableName, List<BtmTypeAttributeVO> attributeVOList) { |
| | | String attributeSql = dllMapper.getCreateSqlByAttributeForBtm(attributeVOList); |
| | | //先判断表格是否存在 |
| | | boolean tableExist = false; |
| | |
| | | * @param tableName 表格名称 |
| | | * @param attributeVOList 属性对象列表 |
| | | */ |
| | | private void commentColumnsForTable(String tableName, List<OmdBtmTypeAttributeVO> attributeVOList) { |
| | | private void commentColumnsForTable(String tableName, List<BtmTypeAttributeVO> attributeVOList) { |
| | | if (StringUtils.isNotBlank(tableName) && !CollectionUtils.isEmpty(attributeVOList)) { |
| | | attributeVOList.stream().forEach(s -> { |
| | | ddlMapper.commentColumnTable(tableName, s.getId(), s.getName()); |
| | |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public void changeColumnForLink(List<OsLinkTypeAttributeVO> modifyLengthAttrDOListForLinkType) throws VciBaseException { |
| | | public void changeColumnForLink(List<LinkTypeAttributeVO> modifyLengthAttrDOListForLinkType) throws VciBaseException { |
| | | |
| | | } |
| | | |
| | |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public void addColumn2TableForBtm(List<OmdBtmTypeAttributeVO> addAttrDOList) throws VciBaseException { |
| | | public void addColumn2TableForBtm(List<BtmTypeAttributeVO> addAttrDOList) throws VciBaseException { |
| | | VciBaseUtil.alertCollectionNotNull("要添加到数据库表中的属性集", addAttrDOList); |
| | | Map<String, List<OmdBtmTypeAttributeVO>> btmTypeHasAttributeVOMap = addAttrDOList.stream().collect(Collectors.groupingBy(OmdBtmTypeAttributeVO::getPkBtmType)); |
| | | Map<String, List<BtmTypeAttributeVO>> btmTypeHasAttributeVOMap = addAttrDOList.stream().collect(Collectors.groupingBy(BtmTypeAttributeVO::getPkBtmType)); |
| | | btmTypeHasAttributeVOMap.forEach((k, v) -> { |
| | | OmdBtmTypeVO btmTypeVO = OmdBtmTypeCache.getDetail(k); |
| | | BtmTypeVO btmTypeVO = BtmTypeCache.getDetail(k); |
| | | if (btmTypeVO == null || StringUtils.isBlank(btmTypeVO.getOid())) { |
| | | throw new VciBaseException("要修改属性列长度的业务类型不存在"); |
| | | } |
| | |
| | | * @param attributeVOList 属性的显示对象 |
| | | * @throws VciBaseException 执行或者获取sql语句的时候出现错误会抛出异常 |
| | | */ |
| | | <<<<<<< HEAD |
| | | private void addColumnForTable(String tableName, List<OmdBtmTypeAttributeVO> attributeVOList) throws VciBaseException{ |
| | | ======= |
| | | private void addColumnForTable(String tableName, List<BtmTypeAttributeVO> attributeVOList) { |
| | | >>>>>>> dd3a6c681f938fd53d5f6cc3a4fcee40e71b259c |
| | | String attributeSql = dllMapper.getCreateSqlByAttributeForBtm(attributeVOList); |
| | | //先判断表格是否存在 |
| | | if (!checkTableExistByTableName(tableName)) { |
| | | OmdBtmTypeAttributeVO attributeVO = attributeVOList.get(0); |
| | | BtmTypeAttributeVO attributeVO = attributeVOList.get(0); |
| | | createDbTables(attributeVO.getPkBtmType()); |
| | | } else { |
| | | ddlMapper.addColumn2TableBySql(tableName, attributeSql); |
| | |
| | | * @throws VciBaseException 执行出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public void addColumn2TableForLink(List<OsLinkTypeAttributeVO> addAttrDOListForLinkType) throws VciBaseException { |
| | | public void addColumn2TableForLink(List<LinkTypeAttributeVO> addAttrDOListForLinkType) throws VciBaseException { |
| | | |
| | | } |
| | | |
| | |
| | | * @return 不同的地方,每一个业务类型或者链接类型一条数据 |
| | | */ |
| | | @Override |
| | | public List<OsModifyAttributeInfoDO> checkDifferent(List<OmdBtmTypeVO> btmTypeVOList, List<OsLinkTypeVO> linkTypeVOList) throws VciBaseException { |
| | | public List<ModifyAttributeInfoDO> checkDifferent(List<BtmTypeVO> btmTypeVOList, List<LinkTypeVO> linkTypeVOList) throws VciBaseException { |
| | | return null; |
| | | } |
| | | |
| | |
| | | * @throws VciBaseException 参数为空或者执行出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public void reflexDifferent(List<OsModifyAttributeInfoDO> differentAttributeList) throws VciBaseException { |
| | | public void reflexDifferent(List<ModifyAttributeInfoDO> differentAttributeList) throws VciBaseException { |
| | | |
| | | } |
| | | |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R submitBtmType(OmdBtmTypeDTO dto) { |
| | | public R submitBtmType(BtmTypeDTO dto) { |
| | | VciBaseUtil.alertNotNull(dto, "业务类型", dto.getAttributesDTOList(), "业务类型属性"); |
| | | OmdBtmTypeVO btmTypeVO = Objects.requireNonNull(BeanUtil.copy(dto, OmdBtmTypeVO.class)); |
| | | BtmTypeVO btmTypeVO = Objects.requireNonNull(BeanUtil.copy(dto, BtmTypeVO.class)); |
| | | if (Func.isNotBlank(dto.getTableName())) { |
| | | checkModifyOrCreateTable(btmTypeVO); |
| | | } else { |
| | |
| | | * |
| | | * @param btmTypeVO 业务类型 |
| | | */ |
| | | private void checkModifyOrCreateTable(OmdBtmTypeVO btmTypeVO) { |
| | | private void checkModifyOrCreateTable(BtmTypeVO btmTypeVO) { |
| | | if (checkTableExistByTableName(btmTypeVO.getTableName())) { |
| | | // 表已存在,校验属性 |
| | | List<OmdBtmTypeVO> vos = new ArrayList<>(); |
| | | List<BtmTypeVO> vos = new ArrayList<>(); |
| | | vos.add(btmTypeVO); |
| | | List<OsModifyAttributeInfoDO> differentAttributeList = checkDifferent(vos, null); |
| | | List<ModifyAttributeInfoDO> differentAttributeList = checkDifferent(vos, null); |
| | | if (CollectionUtils.isEmpty(differentAttributeList)) { |
| | | // 可以直接删除再创建 |
| | | dropTableByName(btmTypeVO.getTableName()); |