| | |
| | | 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.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | |
| | | /** |
| | | * 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"; |
| | | |
| | |
| | | |
| | | private final Map<String, LinkTypeVO> idLinkMap = new ConcurrentHashMap<>(); |
| | | |
| | | private void putBtm(@NotNull BtmTypeVO... voList) throws ServiceException { |
| | | private void putBtm(@NotNull BtmTypeVO... voList) throws Throwable { |
| | | String collect = Arrays.stream(voList).map(BtmTypeVO::getId).filter(idBtmMap::containsKey).collect(Collectors.joining(",")); |
| | | if (StringUtils.isBlank(collect)) { |
| | | Arrays.stream(voList).forEach(vo -> { |
| | | idBtmMap.put(vo.getId(), vo); |
| | | }); |
| | | } else { |
| | | throw new ServiceException("业务类型:[" + collect + "]正在被其他用户操作"); |
| | | throw new Throwable("业务类型:[" + collect + "]正在被其他用户操作"); |
| | | } |
| | | } |
| | | |
| | | private void putLink(@NotNull LinkTypeVO... voList) throws ServiceException { |
| | | private void putLink(@NotNull LinkTypeVO... voList) throws Throwable { |
| | | String collect = Arrays.stream(voList).map(LinkTypeVO::getId).filter(idLinkMap::containsKey).collect(Collectors.joining(",")); |
| | | if (StringUtils.isBlank(collect)) { |
| | | Arrays.stream(voList).forEach(vo -> { |
| | | idLinkMap.put(vo.getId(), vo); |
| | | }); |
| | | } else { |
| | | throw new ServiceException("链接类型:[" + collect + "]正在被其他用户操作"); |
| | | throw new Throwable("链接类型:[" + collect + "]正在被其他用户操作"); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) { |
| | | public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) throws Throwable { |
| | | 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 = changedList.isEmpty() ? "数据库操作成功" : changedList.get(0).getHandleResult(); |
| | | R<List<ModifyAttributeInfo>> result = R.success(msg); |
| | | 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()); |