| | |
| | | package com.vci.ubcs.ddl.service.impl; |
| | | |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException; |
| | | import com.vci.ubcs.ddl.bo.DdlTableBO; |
| | | import com.vci.ubcs.ddl.bo.DdlTableInDataBaseBO; |
| | | import com.vci.ubcs.ddl.enums.BusinessTypeEnum; |
| | | import com.vci.ubcs.ddl.enums.ModifyTableTaskEnum; |
| | | import com.vci.ubcs.ddl.processor.ddl.DdlMapperProcessStrategy; |
| | | import com.vci.ubcs.ddl.processor.ddl.DdlMapperProcessor; |
| | | import com.vci.ubcs.ddl.processor.dll.DllMapperProcessor; |
| | | import com.vci.ubcs.ddl.processor.dll.DllMapperProcessorStrategy; |
| | | import com.vci.ubcs.ddl.properties.DdlPropertise; |
| | | import com.vci.ubcs.ddl.service.IDdlService; |
| | | import com.vci.ubcs.omd.cache.BtmTypeCache; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.rmi.ServerException; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | |
| | | /** |
| | | * ddl数据操作服务 |
| | | */ |
| | | private final DdlMapperProcessor ddlMapper = DdlMapperProcessStrategy.getProcessor(); |
| | | @Autowired |
| | | private DdlMapperProcessor ddlMapper; |
| | | |
| | | |
| | | /** |
| | | * dll数据操作服务 |
| | | */ |
| | | private final DllMapperProcessor dllMapper = DllMapperProcessorStrategy.getProcessor(); |
| | | @Autowired |
| | | private DllMapperProcessor dllMapper; |
| | | |
| | | private static final String YES = "Y"; |
| | | |
| | |
| | | if (StringUtils.isNotBlank(s.getModifyAttributes()) || StringUtils.isNotBlank(s.getDeleteAttributes())) { |
| | | //需要去判断是否可以更改 |
| | | if (checkTableHasDataByTableName(s.getTableName())) { |
| | | //有数据的话,得需要判断属性是否可以修改 |
| | | //有数据的话,得需要判断属性是否可以删除 |
| | | if (StringUtils.isNotBlank(s.getDeleteAttributes())) { |
| | | s.setHandleResult("表格存在数据,不允许删除字段"); |
| | | s.setHandleResult("表格存在数据,不允许删除"+ s.getDeleteAttributes() +"字段"); |
| | | return; |
| | | } |
| | | List<DdlTableInDataBaseBO> columnInDbList = selectTableColumnInfo(s.getTableName()); |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) { |
| | | public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) throws ServerException { |
| | | try { |
| | | List<ModifyAttributeInfo> changedList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(ddlDTO.getBtmTypeList())) { |
| | |
| | | changedList.addAll(checkDifferent(null,linkTypeList)); |
| | | removeLink(linkTypeList.toArray(new LinkTypeVO[0])); |
| | | } |
| | | R<List<ModifyAttributeInfo>> result = R.success("数据库操作成功"); |
| | | String msg = "数据库操作成功"; |
| | | R<List<ModifyAttributeInfo>> result = new R<>(); |
| | | if((!changedList.isEmpty())&&Func.isEmpty(changedList.get(0).getHandleResult())){ |
| | | result = R.success(msg); |
| | | }else { |
| | | result = R.fail(changedList.get(0).getHandleResult()); |
| | | } |
| | | result.setData(changedList); |
| | | return result; |
| | | } catch (ServiceException e) { |
| | | throw new RuntimeException(e.getMessage()); |
| | | } catch (Exception e) { |
| | | try { |
| | | // 建表失败有异常,捕获后返回,并释放线程中的内容 |
| | | if (!CollectionUtils.isEmpty(ddlDTO.getBtmTypeList())) { |
| | | removeBtm(ddlDTO.getBtmTypeList().toArray(new BtmTypeVO[0])); |
| | | } |
| | | if (!CollectionUtils.isEmpty(ddlDTO.getLinkTypeList())) { |
| | | removeLink(ddlDTO.getLinkTypeList().toArray(new LinkTypeVO[0])); |
| | | } |
| | | return R.fail(e.getMessage()); |
| | | }catch (ServiceException e2){ |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | BtmTypeAttributeVO attributeVO = new BtmTypeAttributeVO(); |
| | | attributeVO.setId(col.getId().toLowerCase()); |
| | | attributeVO.setName(col.getName()); |
| | | attributeVO.setNullableFlag(col.getNullableFlag()); |
| | | attributeVO.setNullableFlag(StringUtils.equals(col.getNullableFlag(), BooleanEnum.TRUE.getValue())); |
| | | attributeVO.setAttributeLength(col.getAttributeLength()); |
| | | attributeVO.setPrecisionLength(col.getPrecisionLength()); |
| | | attributeVO.setScaleLength(col.getScaleLength()); |