wangting
2023-07-21 bfedaf0182cac8fb947f1b0a3dee3d07c3c24f1e
Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
@@ -486,8 +486,9 @@
    * @return 执行结果
    */
   @Override
   public R submit(BtmTypeDTO btmTypeDTO, boolean autoCreateTable) {
      TransactionStatus transaction = null;
   @Transactional(rollbackFor = Exception.class)
   public R submit(BtmTypeDTO btmTypeDTO, boolean autoCreateTable) throws ServiceException {
      /*TransactionStatus transaction = null;
      DefaultTransactionDefinition def = null;
      if (autoCreateTable) {
         def = new DefaultTransactionDefinition();
@@ -495,7 +496,7 @@
         // 事物隔离级别,开启新事务,这样会比较安全些。
         transaction = dataSourceTransactionManager.getTransaction(def);
         // 获得事务状态
      }
      }*/
      checkBtmTypeBeforeSave(btmTypeDTO);
      BtmType btmTypeDO = Optional.ofNullable(BeanUtil.copy(btmTypeDTO, BtmType.class)).orElseGet(BtmType::new);
      btmTypeDO.setBizDomain(btmTypeDTO.getBizDomain());
@@ -523,7 +524,7 @@
      btmTypeVO.setAttributes(afterAttributes);
      try {
         if (autoCreateTable) {
//            checkTableSame(btmTypeVO);
            // checkTableSame(btmTypeVO);
            R result = DomainRepeater.submitBtmType(btmTypeDTO.getBizDomain(), btmTypeVO);
            if (result.isSuccess()){
               List<ModifyAttributeInfo> infoList = new ArrayList<>();
@@ -538,15 +539,17 @@
                  });
                  modifyAttributeService.saveBatch(ModifyAttributeWrapper.build().listEntityBeforeSave(infoList));
               }
               dataSourceTransactionManager.commit(transaction);
               // dataSourceTransactionManager.commit(transaction);
            }else {
               dataSourceTransactionManager.rollback(transaction);
               return R.fail(result.getMsg());
               // dataSourceTransactionManager.rollback(transaction);
               // 创建表报错,抛出异常让该方法回滚
               throw new VciBaseException(result.getMsg());
               // return R.fail(result.getMsg());
            }
         }
      } catch (Throwable e) {
         if (autoCreateTable) {
            dataSourceTransactionManager.rollback(transaction);
//            dataSourceTransactionManager.rollback(transaction);
            throw new VciBaseException(e.getMessage());
         }
      }