| | |
| | | * @throws ServiceException 参数为空的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public String getTableName(String id,String domain) throws ServiceException { |
| | | public String getTableName(String id,String domain) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(id,"业务类型英文名称",domain,"领域名称"); |
| | | if (domain.contains("ubcs-")){ |
| | | domain = domain.split("ubcs-")[1]; |
| | |
| | | * @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(); |
| | |
| | | // 事物隔离级别,开启新事务,这样会比较安全些。 |
| | | transaction = dataSourceTransactionManager.getTransaction(def); |
| | | // 获得事务状态 |
| | | } |
| | | checkBtmTypeBeforeSave(btmTypeDTO); |
| | | }*/ |
| | | // checkBtmTypeBeforeSave(btmTypeDTO); |
| | | BtmType btmTypeDO = Optional.ofNullable(BeanUtil.copy(btmTypeDTO, BtmType.class)).orElseGet(BtmType::new); |
| | | btmTypeDO.setBizDomain(btmTypeDTO.getBizDomain()); |
| | | List<BtmTypeLinkAttributesDTO> attributes = btmTypeDTO.getAttributes(); |
| | |
| | | List<BtmTypeAttributeVO> beforeAttributes = btmTypeByOid.getAttributes(); |
| | | // 处理属性,多余的删除,不存在的添加 |
| | | afterAttributes = updateAttributeForBtm(btmTypeByOid.getOid(),beforeAttributes, attributes); |
| | | baseMapper.updateByPrimaryKey(btmTypeDO); |
| | | } |
| | | BtmTypeVO btmTypeVO = BtmTypeWrapper.build().entityVO(btmTypeDO); |
| | | //在创建表的时候还需要把默认的字段带上。 |
| | |
| | | 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<>(); |
| | |
| | | }); |
| | | 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()); |
| | | } |
| | | } |
| | |
| | | List<BtmTypeAttributeVO> voListAdd = btmTypeAttributeService.checkAndInsert(oid, addList, AuthUtil.getUserAccount(), new Date()); |
| | | List<BtmTypeAttributeVO> voListUpdate = btmTypeAttributeService.checkAndUpdate(oid, modifyList, AuthUtil.getUserAccount(), new Date()); |
| | | List<BtmTypeAttributeVO> returnList = new ArrayList<>(); |
| | | returnList.addAll(Objects.requireNonNull(voListAdd)); |
| | | returnList.addAll(Objects.requireNonNull(voListUpdate)); |
| | | if(!CollectionUtils.isEmpty(voListAdd)) { |
| | | returnList.addAll(Objects.requireNonNull(voListAdd)); |
| | | } |
| | | if(!CollectionUtils.isEmpty(voListUpdate)) { |
| | | returnList.addAll(Objects.requireNonNull(voListUpdate)); |
| | | } |
| | | return returnList; |
| | | } |
| | | |