田源
2024-01-31 03ab24af158dba0d506569d7e7cf22929ae67296
Source/UBCS/ubcs-service/ubcs-ddl/src/main/java/com/vci/ubcs/ddl/service/impl/DdlServiceImpl.java
@@ -1,6 +1,5 @@
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;
@@ -33,8 +32,8 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.rmi.ServerException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@@ -81,25 +80,25 @@
   private final Map<String, LinkTypeVO> idLinkMap = new ConcurrentHashMap<>();
   private void putBtm(@NotNull BtmTypeVO... voList) throws Throwable {
   private void putBtm(@NotNull BtmTypeVO... voList) throws ServiceException {
      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 Throwable("业务类型:[" + collect + "]正在被其他用户操作");
         throw new ServiceException("业务类型:[" + collect + "]正在被其他用户操作");
      }
   }
   private void putLink(@NotNull LinkTypeVO... voList) throws Throwable {
   private void putLink(@NotNull LinkTypeVO... voList) throws ServiceException {
      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 Throwable("链接类型:[" + collect + "]正在被其他用户操作");
         throw new ServiceException("链接类型:[" + collect + "]正在被其他用户操作");
      }
   }
@@ -765,9 +764,9 @@
            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());
@@ -976,7 +975,7 @@
    * @return 执行结果
    */
   @Override
   public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) throws Throwable {
   public R<List<ModifyAttributeInfo>> submit(BtmAndLinkTypeDdlDTO ddlDTO) throws ServerException {
      try {
         List<ModifyAttributeInfo> changedList = new ArrayList<>();
         if (!CollectionUtils.isEmpty(ddlDTO.getBtmTypeList())) {
@@ -991,7 +990,13 @@
            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 (Exception e) {